C Programming language

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

A
B  B
C  C  C
D  D  D  D
E  E  E  E  E

In this example we are going to make a triangle which have A in first row B B into second row ,C C C in second row and so on. For this we are using two for loops.

#include<stdio.h>
#include<conio.h>
void main()
{
	int i,j;
	int n;
	clrscr();
	printf("Enter the ASCII character\t");
	scanf("%d",&n);
	for(i=65;i<=n;i++)
	{
		for(j=65;j<=i;j++)
			printf("%c",i);
		printf("\n");
	}
	getch();
}
Output: Enter the ASCII character 70

A
B  B
C  C  C
D  D  D  D
E  E  E  E  E

Previous Home Next