Q. Write a C program to make T shape character pattern design as:
DCBABCD
CBABC
BAB
A
Ans.
/*c source code for T shape pyramid pattern program*/
#include<stdio.h>
int main()
{
int i;
char ch,r,c,p,q,sp;
printf("Enter seed character : ");
scanf("%c", &ch);
if(ch>='a' && ch<='z')
ch=ch-32;
printf("\n");
for(r='A',q=ch; r<=ch; r++,q--)
{
for(sp=r; sp>'A'; sp--)
printf(" ");
for(c=r,p=q; c<=ch; c++,p--)
printf("%c",p);
for(i=ch-r,p='B'; i>=1; i--,p++)
printf("%c",p);
printf("\n");
}
getch();
return 0;
}
You might also like to read:
1. Big list of 98+ C pyramid programs
2. Latest user asking pyramid programs list
3. T-Shape Number Pyramid C program as:
4321234
32123
212
1
DCBABCD
CBABC
BAB
A
Ans.
/*c source code for T shape pyramid pattern program*/
#include<stdio.h>
int main()
{
int i;
char ch,r,c,p,q,sp;
printf("Enter seed character : ");
scanf("%c", &ch);
if(ch>='a' && ch<='z')
ch=ch-32;
printf("\n");
for(r='A',q=ch; r<=ch; r++,q--)
{
for(sp=r; sp>'A'; sp--)
printf(" ");
for(c=r,p=q; c<=ch; c++,p--)
printf("%c",p);
for(i=ch-r,p='B'; i>=1; i--,p++)
printf("%c",p);
printf("\n");
}
getch();
return 0;
}
/*******************************************************
The output of above program would be:
*******************************************************/
Figure: Screen shot for T-Shape Character pyramid C program |
You might also like to read:
1. Big list of 98+ C pyramid programs
2. Latest user asking pyramid programs list
3. T-Shape Number Pyramid C program as:
4321234
32123
212
1
0 komentar:
Post a Comment