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

Can you pass an entire structure to functions?

906


Why & is used in scanf in c?

809


Why c is called a middle level language?

829


What are local static variables? How can you use them?

848


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

2002


What is the difference between pure virtual function and virtual function?

874


Why string is used in c?

757


What is static and volatile in c?

981


What does struct node * mean?

803


Why c is called object oriented language?

813


What is scanf_s in c?

848


What is the advantage of using #define to declare a constant?

850


If I have a char * variable pointing to the name of a function ..

908


Can we assign integer value to char in c?

824


main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none

1031