C Program to Print Triangle of Stars
Write a program in the C programming language to print the triangle of stars. Make a right angled triangle. You can also print any other character of your choice. Below is the pattern of the triangle-
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
This C program is made by using the nested for loops to print asterisks . Below is the code of the program-
/* C program to print triangle of stars or of any other character */
#include<stdio.h>
void main()
{
int n,i;
for(n=1;n<=20;n++)
{
for(i=1;i<=n;i++)
{
printf("*");
}
printf("\n");
}
getch();
}
Output – Output will be same as the triangle made above
No comments yet