Read array of 10 integers and displaying them.
“Array is the limited storage(as size mentioned) with ordered series or arrangement of same kind of data(int or float or char)”
Example :Input is asked as : Enter the Array elements,
Enter Values like 00,10,20,30,40,50,60,70,80,90 are stored in particular space of array.
Example:
– This represents that the data collection is done in one array.
– This data storage array starts from a[0], 0 refers to starting starting index i.e. a[0] and continues till a[7].
– a[0],a[1],a[2],……….a[9], each address has its individual data storing capacity.
Sample Code for Storing of data(10 integer’s) in an Array and displaying it:
#include <iostream> //Header file. using namespace std; void read(int []); //reading a data stored in an array void display(int []); //displaying the data stored in an array main() { int a[10]; //array has 10 integer's in it read(a); display(a); } void read(int a[]) //read function { cout<<"Enter the number"; for(int i=0;i<10;i++) //i=0 refers to array address starts from 0, and its less than 10,(it doesn't exceed more then 9(i= 0 to i=9). Every time after 1 iteration, 'i' gets incremented, till i reaches 9) cin>>a[i]; } void display(int a[]) //display function { cout<<"Enter the Array elements"; for(int i=0;i<10;i++) cout<<endl<<a[i]; }
Result of the Program:
Input asked: Enter the number:
00
10
20
30
40
50
60
70
80
90
Output showed: 00
10
20
30
40
50
60
70
80
90