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 / venkatesh
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int i,j,k,n1,n2;
printf("
enter n1 value:");
scanf("%d",&n1);
k=4;
for(i=1;i<=n1;)
{
for(j=i;j<=2*i;j++)
{
printf("%d ",k);
}
printf("
");
i=i+2;
k=k-1;
}
k=0;
n2=n1+1;
for(i=9;i>=1;)
{
for(j=1;j<=i;j++)
{
printf("%d ",k);
}
printf("
");
k=k+1;
i=i-2;
}
return 0;
}
Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
How can I access an I o board directly?
Combinations of fibanocci prime series
Who invented b language?
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
Can a file other than a .h file be included with #include?
How can I recover the file name given an open stream?
What is the function of multilevel pointer in c?
Difference between MAC vs. IP Addressing
How to draw the flowchart for structure programs?
How can I write a function analogous to scanf?
What is an endless loop?
What is the scope of an external variable in c?
can we change the default calling convention in c if yes than how.........?
Explain what is the difference between null and nul?
What is wrong with this statement? Myname = 'robin';