Triangle of Numbers Program in C Programming

In C Programming Language we can make many type of shape using numbers and other characters. Here I will show how we can create triangle with number. Please see the below program. Comment here for any questions.

We can create various triangle pattern using C Program as follow:

 Triangle C Program 1:

/**
Write a C program to create triangle as follow
1
12
123
1234
12345
**/

#include<stdio.h>
#include<conio.h>
void main()
{
	int x,y;
	clrscr();
	for(x=1;x<=5;x++)
	{
		for(y=1;y<=x;y++)
		{
			printf("%d",y);
		}
		printf("\n");
	}
	getch();
}

Output of Program:

1
12
123
1234
12345

 Triangle C Program 2:

/**
Write a C program to create triangle as follow
1
21
321
4321
54321
**/

#include<stdio.h>
#include<conio.h>
void main()
{
	int x,y,z;
	clrscr();
	for(x=1;x<=5;x++)
	{
	for(y=x;y>=1;y--)
	{
	printf("%d",y);
	}
	printf("\n");
	}

getch();
}

 Output of Program:

1
21
321
4321
54321

 Triangle C Program 3:

/**
Write a C program to create triangle as follow
1
22
333
4444
55555
**/

#include<stdio.h>
#include<conio.h>
void main()
{
	int x,y;
	clrscr();
	for(x=1;x<=5;x++)
	{
	for(y=1;y<=x;y++)
	{
	printf("%d",x);
	}
	printf("\n");
	}
getch();
}

 Output of Program:

1
22
333
4444
55555

 Triangle C Program 4:

/**
Write a C program to create triangle as follow
12345
2345
345
45
5
**/

#include<stdio.h>
#include<conio.h>
void main()
{
	int x,y,z;
	clrscr();
	for(x=1;x<=4;x++)
	{
	for(z=1;z<=x;z++)
	{
	printf(" ");
	}
	for(y=x;y>=1;y--)
	{
	printf("*");
	}
	printf("\n");
	}
getch();
}

 Output of Program:

1 2 3 4 5
2 3 4 5
3 4 5
4 5
5

Please comment here if you have any questions