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

How can I ensure that integer arithmetic doesnt overflow?

609


How can I read in an object file and jump to locations in it?

582


What is a loop?

557


What is the difference between far and near ?

688


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

612






praagnovation

1780


PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE

1473


Explain union.

639


What is the purpose of clrscr () printf () and getch ()?

598


How many types of arrays are there in c?

596


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

611


What is the use of define in c?

598


Why is a semicolon (;) put at the end of every program statement?

629


What are the properties of union in c?

591


code for find determinent of amatrix

1520