Friday, September 6, 2013

Number Pyramid Structure

Q. Write a C program to print the following number pyramid structure design as:

1 2 3 4 5
2 3 4 5
3 4 5
4 5
5

Ans.

/*c program for number pyramid pattern design*/
#include<stdio.h>
int main()
{

 int num,r,c;
 printf("Enter no of rows : ");
 scanf("%d", &num);
 for(r=1; r<=num; r++)
 {
  for(c=r; c<=num; c++)
     printf("%d ",c);
  printf("\n");
 }
 getch();
 return 0;
}

/*************************************************************
The output of number pyramid pattern design program would be:
**************************************************************/


Output of Number Pyramid Pattern C program
Figure: Screen-shot for number pyramid pattern C program


No comments:

Post a Comment