How can an array be explicitly initialized at run time?



An array can also be explicitly initialized at run time. For ex – consider the following segment of a C program.
      for(i=0;i<10;i++)
      {
            scanf(" %d ", &x[i] );
      }

Above example will initialize array elements with the values entered through the keyboard. In the run time initialization of the arrays looping statements are almost compulsory. Looping statements are used to initialize the values of the arrays one by one by using assignment operator or through the keyboard by the user.
Next Post Previous Post
No Comment
Add Comment
comment url