- Back to Home »
- PATTERN PROGRAMS »
- C PROGRAM TO PRINT ABC TRIANGLE PATTERN
Posted by : ANIMESH SHAW
Tuesday, 20 September 2011
#include <stdio.h>
#include<conio.h>
main()
{
int i, j, k;
char ch;
i = 0;
while(i <= 5)
{
j = 5;
ch = 'A';
printf("\n");
while(j >= i)
{
printf("%c", ch);
j--;
ch++;
}
j = 1;
while(j <= (2 * i - 1))
{
printf("-");
j++;
}
if(i == 0)
ch -= 2;
else ch--;
while(ch >= 'A')
{
printf("%c", ch);
ch--;
}
i++;
}
getch();
}
#include<conio.h>
main()
{
int i, j, k;
char ch;
i = 0;
while(i <= 5)
{
j = 5;
ch = 'A';
printf("\n");
while(j >= i)
{
printf("%c", ch);
j--;
ch++;
}
j = 1;
while(j <= (2 * i - 1))
{
printf("-");
j++;
}
if(i == 0)
ch -= 2;
else ch--;
while(ch >= 'A')
{
printf("%c", ch);
ch--;
}
i++;
}
getch();
}

Post a Comment