C Programming |
How To Design Taj Mahal Shape Pyramid Posted: 01 Feb 2015 04:11 AM PST Q. Write a C program to print the following Taj Mahal Shape pyramid as: * *** ***** ******* ** **** ****** ******* ****** **** ** ******* ***** *** * Ans. /*c program for Taj Mahal shape pyramid*/ #include<stdio.h> int main() { int r,c,w,x,y,z; for(r=1,z=1; r<=4; r++,z=z+2) { for(c=1; c<=z; c++) printf("*"); printf("\n"); } for(r=1,y=2; r<=3; r++,y=y+2) { for(c=1; c<=y; c++) printf("*"); printf("\n"); } for(r=1; r<=7; r++) printf("*"); printf("\n"); for(r=1,x=6; r<=3; r++,x=x-2) { for(c=1; c<=x; c++) printf("*"); printf("\n"); } for(r=1,w=7; r<=4; r++,w=w-2) { for(c=1; c<=w; c++) printf("*"); 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