C Programming |
How to Make a Continuous Diagonal Number Pyramid C program Posted: 11 Aug 2014 12:06 PM PDT Q. Write a C program to print the following continues odd reverse number pyramid pattern as: 1 6 2 10 7 3 13 11 8 4 15 14 12 9 5 Ans. Before we start to write the code for above continuous diagonal number pyramid C program, let's focus on below image for better understand the structure of pattern.
/*c program for continuous diagonal number pyramid pattern*/ #include<stdio.h> int main() { int num,r,c,m,n,z,a; printf("Enter No. of Rows : "); scanf("%d", &num); z=num; n=1; for(r=1; r<=num; r++, n=n+7-r, z--) { m=n; a=num-r; for(c=1; c<=r; c++, m=m-a) { printf(" %d ", m); a++; } printf("\n"); } getch(); return 0; } /************************************************************* The output of above Continuous Diagonal number pyramid pattern C program ***************************************************************/
You might also like: |
You are subscribed to email updates from C Programming To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
Post a Comment