Monday 10 February 2020

CPP program to display the 5 elements of an array of size 10 using loop

Source Code:
#include<iostream>
using namespace std;
int main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
cout<<"To display upto the 5th element of the array: ";
for(int i=1;i<=5;i++)
{
cout<<a[i];
}
return 0;
}

Program Output:

No comments:

Post a Comment