C++ language

adplus-dvertising
Program Of Array
Previous Home Next

A Simple Array Example Using C++

#include<stdio.h>
#include<conio.h>
int main()
{
int myarray[5];
int i;
for(i=0;i<5;i++)
{
cout<<"Enter the value for array"["<<i<<"];

cin>>myarray[i];
}
for(i=0;i<5;i++)
cout<<i<<" : "myarray[i]<<"\n;"
return 0;
}

Output:

Enter the value of array[0] 3
Enter the value of array[1] 6
Enter the value of array[2] 9
Enter the value of array[3] 12
Enter the value of array[4] 15
0:3
1:6
2:9
3:12
4:15
Previous Home Next