write a program to display the numbers in the following
format
4 4
3 3 3 3
2 2 2 2 2 2
1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1
2 2 2 2 2
3 3 3
4

Answer Posted / vamsi talapatra

#include<iostream>
using namespace std;
int main(){
int n = 4;
int e = 2;
while(n>0){
for(int i = 0; i< e ; i++){
cout<<n<<" ";
}
cout<<endl;
e=e+2;
n--;
}

while(n<=4){
for(int i = 1; i< e ; i++){
cout<<n<<" ";
}
cout<<endl;
e=e-2;
n++;
}
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how can I manipulate strings of multibyte characters?

767


Here is a good puzzle: how do you write a program which produces its own source code as output?

587


Can you write the algorithm for Queue?

1536


What are the characteristics of arrays in c?

599


Is anything faster than c?

571






Tell me what is null pointer in c?

597


When should the register modifier be used? Does it really help?

594


What is a macro, and explain how do you use it?

615


What is size of union in c?

567


What are the disadvantages of external storage class?

576


Why is struct padding needed?

619


the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above

592


What are the application of void data type in c?

677


What is the time and space complexities of merge sort and when is it preferred over quick sort?

661


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

629