C Programming language

adplus-dvertising
C Program example: Print alphabets triangle
Previous Home Next

In this example we are going to print A in first row .In second row we are going to print A B , in third line we are going to print A B C and so on. For this we are using two for loop .First for loop is used for row and second is used to print column. We are using %c to print the character value of integer.

/*  A             */
/*  A B           */
/*  A B C         */
/*  A B C D       */
/*  A B C D E     */

#include<stdio.h>
#include<conio.h>
void main()      
{                
	int i,j;         
	clrscr();        
	for(i=65;i<=69;i++)
	{
		for(j=65;j<=i;j++)
			printf("%c",j);
		printf("\n");
	}
	getch();
}
Output:
A             
A B           
A B C         
A B C D       
A B C D E     
Previous Home Next