4.17.2013

Reverse Number Pyramid

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:

Output for reverse number pyramid C program
Figure: Screen shot for number pyramid C program

2 comments:

  1. give the source code of largest of 3 numbers and largest of 10 no.

    ReplyDelete
  2. 1 2 3 4 5
    15 14 13 12
    6 7 8
    11 10
    9
    plz write program for this output

    ReplyDelete