Skip to main content

Sample program to create an array and print its elements in C++

Here we have created an array which size of 5 and then entered elements into that. Then we have used for loop to print those elements out. we declared an integer type variable 'i' which indicates the index number of the array.

#include<iostream> using namespace std; int main() { int array[5]={1,2,5,7,9}; for(int i=0;i<5;i++) { cout<<array[i]<<endl; } return 0; }

Quote :

People who are crazy enough to think they can change the world,,,ARE THE ONES WHO DO ....