C Programming |
Posted: 06 Feb 2014 09:39 AM PST Q. Write a C program to print the following equal character triangle pattern as: A BAB CBABC DCBABCD EDCBABCDE Ans. /*c program for Equal Character Triangle pattern*/ #include<stdio.h> int main() { char ch,r,c; printf("Enter Any Character : "); scanf("%c", &ch); if(ch>='a' && ch<='z') ch=ch-32; for(r='A'; r<=ch; r++) { for(c=r; c>='A'; c--) printf("%c",c); for(c='B'; c<=r; c++) printf("%c",c); printf("\n"); } getch(); return 0; } /********************************************* The output of above program would be: ********************************************/
Related Program: Equal Number Triangle C program: 1 212 32123 4321234 543212345 | ||
Posted: 06 Feb 2014 09:42 AM PST Q. Write a C program to print the following equal number triangle pattern as: 1 212 32123 4321234 543212345 Ans. /*c program for equal number triangle pattern*/ #include<stdio.h> int main() { int num,r,c; printf("Enter Any Number : "); scanf("%d", &num); for(r=1; r<=num; r++) { for(c=r; c>=1; c--) printf("%d",c); for(c=2; c<=r; c++) printf("%d",c); printf("\n"); } getch(); return 0; } /********************************************************** The output of above program would be: ***********************************************************/
Related Programs: Equal Character Triangle as: A BAB CBABC DCBABCD |
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