Learn C with example
Print alphabet triangle Using C
In
this example we are going to create an alphabets triangle.
In this example we are going to print alphabets
triangle which first line has A, second line B C ,third line D
E F and so on .For this we are using two for loops.
#include<stdio.h>
#include<conio.h> /* A */
void main() /* B C */
{ /* D E F */
int i,j,k=65; /* G H I J */
clrscr(); /* K L M N 0 */
for(i=65;i<=70;i++)
{
for(j=65;j<=i;j++)
printf("%c",k++);
printf("\n");
}
getch();
}
|
Output Of Example
| Triangle from A to
U A
B C
D E F
G H I J
K L M N 0 |