- Back to Home »
- Best Pattern Made from Alphabets (C Program)
#include<stdio.h>
int main()
{
int i,j,k,n,c,c1=0; /*initializing the variables which are needed*/
printf("Please enter the rows for the right and led triangle \n");
scanf("%d",&n);
/*Loop for the upper part of the pattern*/
for(i=n;i>=1;i--)
{
c=64;
for(j=1;j<=i;j++)
{
printf("%c",c+j);
}
for(k=n;k>i;k--)
{
printf(" ");
}
c=65+n-c1;
for(j=1;j<=i;j++)
{
printf("%c",c-j);
}
c1++;
printf("\n");
}
/*loop for lower part */
c1=2;
for(i=2;i<=n;i++)
{
c=64;
for(j=1;j<=i;j++)
{
printf("%c",c+j);
}
for(k=i;k<n;k++)
{
printf(" ");
}
c=65+c1;
for(j=1;j<=i;j++)
{
printf("%c",c-j);
}
c1++;
printf("\n");
}
return 0;
}