Write a program to creat two triangle of alphabets.

A B C D E F G F E D C B A
A B C D E F    F E D C B A
A B C D E         E  D C B A
A B C D               D C B A
A B C                     C B A
A B                           B A
A                                 A

#include<stdio.h>
main()
{
int i,j,k,n;
printf("\nEnter the number of rows::");
scanf("%d",&n);

for(i=0;i<n;i++ )
{ for(j=65;j< 65+n-i; j++)
printf("%c ",j);

for(k=1;k<(4*i-1);k++)
printf(" ");

if(i==0) printf("\b\b");

for(j=j-1;j>=65;j--)
printf("%c ",j);

printf("\n");
}
}
Advertisements

3 thoughts on “Write a program to creat two triangle of alphabets.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s