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 ensure that integer arithmetic doesnt overflow?
How can I read in an object file and jump to locations in it?
What is a loop?
What is the difference between far and near ?
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
praagnovation
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
Explain union.
What is the purpose of clrscr () printf () and getch ()?
How many types of arrays are there in c?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
What is the use of define in c?
Why is a semicolon (;) put at the end of every program statement?
What are the properties of union in c?
code for find determinent of amatrix