Q. Write a C program to print the reverse number pyramid as:
10 9 8 7
6 5 4
3 2
1
Ans.
/*c program for reverse number pyramid*/
#include<stdio.h>
int main()
{
int n=4,num,r,c;
static int p=10;
num = n;
for(r=1; r<=n; r++,num--)
{
for(c=1; c<=num; c++)
{
printf("%d ",p);
p--;
}
printf("\n");
}
getch();
return 0;
}
The output of above program would be:
10 9 8 7
6 5 4
3 2
1
Ans.
/*c program for reverse number pyramid*/
#include<stdio.h>
int main()
{
int n=4,num,r,c;
static int p=10;
num = n;
for(r=1; r<=n; r++,num--)
{
for(c=1; c<=num; c++)
{
printf("%d ",p);
p--;
}
printf("\n");
}
getch();
return 0;
}
The output of above program would be:
Figure: Screen shot for number pyramid C program |
give the source code of largest of 3 numbers and largest of 10 no.
ReplyDelete1 2 3 4 5
ReplyDelete15 14 13 12
6 7 8
11 10
9
plz write program for this output