Defining the Size of an Array
Explore different methods for defining the size of an array.
Defining the size by specifying the size before the array name
We cannot define an array by first specifying the array size and then the array name in square brackets.
❌ Error: The code given below will generate an error.
#include<stdio.h> int main() { int a[5]; /* Uncommenting line 6 will generate an error */ //int 5[b]; // First write array name and then specify subscript in brackets printf("%d ", a[2]); // First specify array subscript and then write array name in square brackets printf("%d ", 2[a]); }
We cannot use the form, ...