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

Write a program to print ASCII code for a given digit.

689


What is the scope of static variable in c?

537


What is meant by inheritance?

635


What is include directive in c?

647


Explain what is meant by high-order and low-order bytes?

636






Explain union.

639


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

674


What are pointers really good for, anyway?

618


Why is extern used in c?

613


What is the use of getchar() function?

631


What is the general form of function in c?

611


What is the basic structure of c?

558


State two uses of pointers in C?

642


What is the difference between int main and void main?

576


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

771