C Programming |
How To Make Half Rhombus Shape Number Triangle Posted: 03 Mar 2015 08:57 AM PST Q. How to make half rhombus number triangle as: 5 456 34567 2345678 123456789 2345678 34567 456 5 Ans. /*c program for half rhombus number triangle*/ #include<stdio.h> int main() { int r,c,j,num,n; printf("Enter Any Number : "); scanf("%d", &num); n=num; for(r=1; r<=num; r++,n--) { for(c=n; c<=num; c++) printf("%d", c); for(c=r, j=num+1; c>1; c--, j++) printf("%d", j); printf("\n"); } for(r=2; r<=num; r++) { for(c=r; c<=num; c++) printf("%d", c); for(c=num-r, j=num+1; c>=1; c--, j++) printf("%d", j); printf("\n"); } getch(); return 0; } /******************************************************** The output of above program would be: ********************************************************/
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., 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
Post a Comment