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
Why header file is used in c?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Explain what is the difference between #include and #include 'file' ?
please give me a VIRTUSA sample palcement papers.... you will only send TECHNICAL SECTION..... that is help for me Advance Thanks........................
write a program to generate address labels using structures?
What is the maximum no. of arguments that can be given in a command line in C.?
Is c language still used?
Why main function is special give two reasons?
What are Macros? What are its advantages and disadvantages?
What is the use of getchar() function?
How can this be legal c?
Differentiate between the expression “++a” and “a++”?
Explain what are compound statements?
What is substring in c?
What is memcpy() function?