How to initialize an array.
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int array[10]; //an array of 10 same data type elements
cout<<"Enter 10 elements : ";
for(int i=0;i<10;i++) // for loop to for getting values for array 10 times
{
cin>>array[i]; //getting values form user
}
cout<<"10 elements you enterd are: ";
for(int i=0;i<10;i++)
{
cout<<array[i]<<" "; //printing all entered values
}
getch();
return 0;
}
#include<conio.h>
using namespace std;
int main()
{
int array[10]; //an array of 10 same data type elements
cout<<"Enter 10 elements : ";
for(int i=0;i<10;i++) // for loop to for getting values for array 10 times
{
cin>>array[i]; //getting values form user
}
cout<<"10 elements you enterd are: ";
for(int i=0;i<10;i++)
{
cout<<array[i]<<" "; //printing all entered values
}
getch();
return 0;
}