C Programming |
Number Triangle Pattern C Program Posted: 09 Aug 2014 09:47 AM PDT Q. Write a C program to print the following number triangle pattern as: 0 101 21012 3210123 432101234 54321012345 Ans. /*c program for number triangle pattern*/ #include<stdio.h> int main() { int num,r,c,m,n; printf("Enter maximum number : "); scanf("%d", &num); for(r=1,m=0; r<=num+1; r++,m++) { for(c=1,n=m; c<=r; c++,n--) printf("%d", n); for(c=1; c<r; c++) printf("%d", c); printf("\n"); } getch(); return 0; } /************************************************************* The output of above number triangle pattern program as ************************************************************/
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