C Programming Tutorial
Computer Tutorial

Reading Data from an Array



Reading Data from an Array

Programs also needs to reads the data back out of the array and uses it to display or calculate the data. An array can access using there name and index.

The general form for reading the data from an array is :

Name of array [array index] ;

Ex:
marks[3] ;

It can display the marks of 4th subject stored in the position 3.

» We also can access or read the all element of array using any of loop

for ( i = 0; i < 5; i ++  )
{

printf("\n Marks = %d ",   marks[i] ) ;

}

Here, The statement will display the marks of 5 subjects. Initially, when i = 0 at first loop, It can print the value of first subject marks stored in marks[0] array element. The loop can iterate upto 5 time, when value of i becomes 5, loop will exit.