Answer to Question #21084 in C++ for apoorva

Question #21084
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
Expert's answer
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS