Monday, 6 March 2017

C program to print following pattern


ABCDEFEDCBA
ABCDE.EDCBA
ABCD      DCBA
ABC           CBA
AB                 BA
A                      A



void main()
{
int i,j,k;
for(i=5;i>=1;i--)
{
for(j=1;j<=5;j++)
{
if(j<=i)
printf("%c",'A' + j-1);
else
printf(" ");
}
for(j=4;j>=1;j--)
{
if(j<=i)
printf("%c",'A' + j-1);
else
printf(" ");
}
printf("\n");
}
}

No comments:

Post a Comment