C Programming |
How To Design A Number Rhombus Pattern C Program Posted: 16 Aug 2014 12:23 PM PDT Q. Write a C program to print the following number rhombus pattern design as: 1 1 2 2 3 3 4 4 5 5 4 4 3 3 2 2 1 1 Ans. /*c program for how to design a number rhombus pattern*/ #include<stdio.h> int main() { int num,r,c,sp,n; printf("Enter maximum number : "); scanf("%d", &num); for(r=1; r<=num; r++) { for(sp=num-r; sp>=1; sp--) printf(" "); printf("%d", r); for(sp=r*2; sp>1; sp--) printf(" "); printf("%d", r); printf("\n"); } for(r=1,n=num-1; r<num; r++,n--) { for(sp=r; sp>=1; sp--) printf(" "); printf("%d",n); for(sp=n*2; sp>1; sp--) printf(" "); printf("%d", n); printf("\n"); } getch(); return 0; } /************************************************************* The output of above number rhombus program: *************************************************************/
You Might Also Like: 1. How to make number rhombus design as: 1 212 32123 4321234 32123 212 1 2. How to make number rhombus design as: 1 121 12321 1234321 12321 121 1 3. How to make a character rhombus design as: A ABA ABCBA ABCDCBA ABCBA ABA A 4. How to make hourglass star design as: ********* ******* ***** *** * *** ***** ******* ********* |
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