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


Please Help Members By Posting Answers For Below Questions

An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above

690


What is the purpose of sprintf() function?

587


‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .

2357


What is a program flowchart?

588


Describe how arrays can be passed to a user defined function

765






What is the difference between array and linked list in c?

581


What is the use of sizeof?

540


What is the difference between a free-standing and a hosted environment?

631


What is the code in while loop that returns the output of given code?

1269


What is the use of pragma in embedded c?

583


What are disadvantages of C language.

633


Are enumerations really portable?

583


What is unsigned int in c?

545


How can I insert or delete a line (or record) in the middle of a file?

562


Why isn't it being handled properly?

632