Silahkan Melihat Tutorial di website kami dengan nyaman ENJOY YOUR LIFE ☕

Continuous Vertical Number Pyramid

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

1
2  7 
3  8  13
4  9  14  19
5 10  15  20  25

Ans.

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

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

/****************************************
The output of above program would be:
***************************************/


output of continuous vertical number pyramid C program
Figure: Screen shot for continuous vertical number pyramid C program






0 komentar:

Post a Comment

Continuous Vertical Number Pyramid