Q. Write a C program for print the following character triangle:
A
BB
CCC
DDDD
EEEEE
Ans.
/*C program for character triangle*/
#include<stdio.h>
#include<conio.h>
int main()
{
char ch,r,c;
printf("Enter last pyramid character : ");
ch=getchar();
if(ch>='a' && ch<='z')
ch=ch-32;
for(r='A'; r<=ch; r++)
{
for(c='A'; c<=r; c++)
printf("%c",r);
printf("\n");
}
return 0;
}
Output:-
Enter last pyramid character : e
A
BB
CCC
DDDD
EEEEE
You might also like:
OR
Q. Write a C program for print the following character pyramid:A
BB
CCC
DDDD
EEEEE
Ans.
/*C program for character triangle*/
#include<stdio.h>
#include<conio.h>
int main()
{
char ch,r,c;
printf("Enter last pyramid character : ");
ch=getchar();
if(ch>='a' && ch<='z')
ch=ch-32;
for(r='A'; r<=ch; r++)
{
for(c='A'; c<=r; c++)
printf("%c",r);
printf("\n");
}
return 0;
}
Output:-
Enter last pyramid character : e
A
BB
CCC
DDDD
EEEEE
You might also like:
Can you do this. Need help please
ReplyDeletea
bb
ccc
dddd
#include
Delete#include
int main()
{
char ch,r,c;
printf("Enter last pyramid character : ");
ch=getchar();
if(ch>='A' && ch<='Z')
ch=ch+32;
for(r='a'; r<=ch; r++)
{
for(c='a'; c<=r; c++)
printf("%c",r);
printf("\n");
}
return 0;
}
EEEEE
ReplyDeleteDDDD
CCC
BB
A
@ Anto,
DeleteYour required above program is :
http://cprogrammingcodes.blogspot.in/2014/01/decrease-character-pyramid.html
#include
ReplyDeleteint main()
{
int i,j;
char ch='A';
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%c",ch);
}
printf("\n");
ch++;
}
return 0;
}
c
ReplyDeleteco
com
comp
compu
comput
compute
computer
hoe to get this output in c program
@Vky Ganesan,
Deletethe source code for above character pattern as following:
#include"stdio.h"
#include"conio.h"
int main()
{
int x,y;
static char str[]="computer";
for(x=0; x<8; x++)
{
y=x+1;
printf("%-5.*s\n",y,str);
}
getch();
return 0;
}
Aa
ReplyDeleteBb Bb
Cc Cc Cc
Dd Dd Dd Dd
how to get this output in c program
@Ketan Bande
DeleteYour required character pattern pyramid source code as following:
#include"stdio.h"
#include"conio.h"
int main()
{
char ch,r,c,z='a';
printf("Enter last pyramid character : ");
ch=getchar();
if(ch>='a' && ch<='z')
ch=ch-32;
for(r='A'; r<=ch; r++,z++)
{
for(c='A'; c<=r; c++)
printf("%c%c ",r,z);
printf("\n");
}
getch();
return 0;
}
This comment has been removed by the author.
ReplyDeletea1
ReplyDeletea2 b3
a4 b5 c6
a7 b8 c9 d10
plz.provide the code for the pattern below
ReplyDeletezywxvwxyz
zyxwxyz
zyxyz
zyz
z
can you do this if we enter number 7
ReplyDeleteits output is
CDBAXYZ
PQRSTU
KLMNO
GH IJ
DEF
CB
A
Can you do
ReplyDeleteA
B B
C C C
D D D D
With function?