Q. Write a C program to print the following character triangle:
ABCDEDCBA
BCDEDCB
CDEDC
DED
E
Ans.
/* c program for character triangle*/
#include<stdio.h>
#include<conio.h>
int main()
{
int sp;
char ch,r,c;
printf("Enter pyramid character : ");
ch=getchar();
if(ch>='a' && ch<='z')
ch=ch-32;
for(r='A'; r<=ch; r++)
{
for(sp=r; sp>'A'; sp--)
printf(" ");
for(c=r; c<=ch; c++)
printf("%c",c);
for(c=ch-1; r<=c; c--)
printf("%c",c);
printf("\n");
}
return 0;
}
Output:-
Enter pyramid character : e
ABCDEDCBA
BCDEDCB
CDEDC
DED
E
ABCDEDCBA
BCDEDCB
CDEDC
DED
E
Ans.
/* c program for character triangle*/
#include<stdio.h>
#include<conio.h>
int main()
{
int sp;
char ch,r,c;
printf("Enter pyramid character : ");
ch=getchar();
if(ch>='a' && ch<='z')
ch=ch-32;
for(r='A'; r<=ch; r++)
{
for(sp=r; sp>'A'; sp--)
printf(" ");
for(c=r; c<=ch; c++)
printf("%c",c);
for(c=ch-1; r<=c; c--)
printf("%c",c);
printf("\n");
}
return 0;
}
Output:-
Enter pyramid character : e
ABCDEDCBA
BCDEDCB
CDEDC
DED
E
can i have a program for this output
ReplyDeleteinput:n=4
output:
H
HOH
HOOOH
HHHHHHH
Can i print the following output
ReplyDeleteA B C D
A B C
A B
A
@Dilllip Kumar Jena,
DeleteYour required character triangle pattern C program source code for above output as:
http://cprogrammingcodes.blogspot.com/2015/08/character-triangle-shape-c-program.html
can u print
ReplyDeleteABCD
ABC
AB
A
@ amey tamhankar,
Deleteyour required character triangle shape C program print source code as:
http://cprogrammingcodes.blogspot.com/2015/08/character-triangle-shape-c-program.html
How to print the output
ReplyDeleteABCDEFGHHGFEDCBA
ABCDEFGGFEDCBA
ABCDEFFEDCBA
ABCDEEDCBA
ABCDDCBA
ABCCBA
ABBA
AA
How to print the output
ReplyDeleteABCDEFGHHGFEDCBA
ABCDEFGGFEDCBA
ABCDEFFEDCBA
ABCDEEDCBA
ABCDDCBA
ABCCBA
ABBA
AA
@ Shafiqah Cd
DeleteYour required character pattern pyramid C program source code :
http://www.cprogrammingcodes.blogspot.com/2012/09/character-pyramid.html
C
ReplyDeleteBCB
ABCBA
BCB
C
give me the solution plsss.....
# Dinesh
DeleteYour required character triangle C program source code as:
http://cprogrammingcodes.blogspot.com/2016/02/character-pattern-of-half-diamond.html