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

Tell me what are bitwise shift operators?

931


Explain output of printf("Hello World"-'A'+'B'); ?

1201


Where static variables are stored in memory in c?

761


What is the heap?

985


what are bit fields? What is the use of bit fields in a structure declaration?

1791


Disadvantages of C language.

867


Explain what is wrong with this program statement? Void = 10;

1017


Which function in C can be used to append a string to another string?

935


Why is structure padding done in c?

911


What are the types of functions in c?

771


Explain how does flowchart help in writing a program?

893


What is the maximum length of an identifier?

928


Can you please compare array with pointer?

853


What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file

903


Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1

3960