Skip to main content

Initialization Methods of Array in C Programming languge


Initialization of Array in C



(a) int x[5]={10,12,14,16,19};

            x[0]=10
            x[1]=12
            x[2]=14
            x[3]=16
            x[4]=19

            All the elements through which we want to initialise the array are given in the curley braces and are  separated by the comma.

(b) int x[5]={10,12,14};

            x[0]=10
            x[1]=12
            x[2]=14

            and the remaining elements will get initlaised with zero.

(c) int x[3]={0};

            In this case , all the elements will get intialised with zero.
           
(d) int x[ ] = {10,12,14,16,18};

            x[0]=10
            x[1]=12
            x[2]=14
            x[3]=16
            x[4]=18

            And the size of the array will get set to 5.As we have given the 5 elements             within the curley braces.

(e)  int x[5]={10,3,44,55,21,23,445,65,656,777,555,34544};

            Error, Too Many Intialisers.







c programming language,c programming software,c programming download,c programming online,c programming examples,c programming tutorial,c programming code
c programming w3schools,c++ compiler download,turbo c compiler,online c compiler,c compiler for windows,c++ compiler,online compiler
online c++ compiler,gdb compiler,c programming practice questions pdf,c programming practice online,c programming coding questions and answers pdf,100 c programming exercises pdf
c programming exercises with solutions pdf for beginners,c programming exercises with solutions book,c programming exercises with solutions,c programming questions
c programs for practice,c program examples,c programs with solutions,simple c programs,c programming examples with output
c programs for practice pdf,c programming practice online,c programming code

Comments