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
Explain how can I manipulate strings of multibyte characters?
Here is a good puzzle: how do you write a program which produces its own source code as output?
Can you write the algorithm for Queue?
What are the characteristics of arrays in c?
Is anything faster than c?
Tell me what is null pointer in c?
When should the register modifier be used? Does it really help?
What is a macro, and explain how do you use it?
What is size of union in c?
What are the disadvantages of external storage class?
Why is struct padding needed?
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
What are the application of void data type in c?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
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