C Programming |
Print Rectangle Pattern Program In C Posted: 18 Apr 2015 06:15 AM PDT Q. Print the rectangle pattern program in C as following design: 1111111 1222221 1233321 1234321 1233321 1222221 1111111 Ans. 1111111 1222221 1233321 1234321 1233321 1222221 1111111 Tips/Tricks: Each color group represent a loop in rectangle pattern program as the below source code written. /* source code for print the rectangle pattern program*/ #include<stdio.h> int main() { int num=4,r,c,m,n,p,q=6; for(r=1; r<=num; r++,q=q-2) { for(c=1; c<=r; c++) printf("%d", c); for(p=q; p>=1; p--) printf("%d", r); for(c=r-1; c>=1; c--) printf("%d", c); printf("\n"); } for(r=3,m=1; r>=1; r--,m=m+2) { for(c=1; c<=r; c++) printf("%d", c); for(n=m; n>=1; n--) printf("%d", r); for(c=r; c>=1; c--) printf("%d", c); 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