Answer to Question #21084 in C++ for apoorva
write a c++ program to display the following:
a)1
2 5
3 6 8
4 7 9 10
b)1
2 3
4 5 6
7 8 9 10
1
2012-12-24T10:01:34-0500
#include <iostream>
using namespace std;
int main()
{
& int a[10];
for(int i=0;i<=10;i++)
{
& a[i]=i;
& }
cout<<"a)"<<endl<<endl;
cout<<a[1]<<endl<<endl;
cout<<a[2]<<" "<<a[5]<<endl<<endl;
cout<<a[3]<<" "<<a[6]<<" "<<a[8]<<endl<<endl;
cout<<a[4]<<" "<<a[7]<<" "<<a[9]<<" "<<a[10]<<endl<<endl<<endl;
cout<<"b)"<<endl<<endl;
cout<<a[1]<<endl<<endl;
cout<<a[2]<<" "<<a[3]<<endl<<endl;
cout<<a[4]<<" "<<a[5]<<" "<<a[6]<<endl<<endl;
cout<<a[7]<<" "<<a[8]<<" "<<a[9]<<" "<<a[10]<<endl<<endl;
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment