What are the rules to be followed while using arrays in C programming?

 In array, it's having some rules like valid data types, declaration part..etc.









RULES :

1) data type should be valid datatype in c including structure and union.

   explanation:

        when you staring any variable name, first your should start writing from the valid data types. Or else you will face some  [Error] 'variable name' undeclared (first use in this function)

2)  then your the array variable name should follow the structure.

       int  varibale_name[size_of_an_array]

3)  the array size should not be a negative integer. it should be a positive integer. 

4)Array index starting from 0 to n-1 values.

if you want to see the highest element in the array you can use the sorting method to get it. 

For taking last elements , we have to use [n-1] . its provides the last element of an array.



1 comment: