#include<stdio.h>
int main()
{
int i,j,rows;
printf("Enter the number of rows: ");
scanf("%d",&rows);
for(i=1; i<=rows; i++)
{
for(j=0; j<i; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Output
Enter the number of rows: 5 * ** *** **** ***** Process returned 0 (0x0) execution time : 1.769 s Press any key to continue.
Code:
#include<stdio.h>
int main()
{
int i,j,rows;
printf("Enter the number of rows: ");
scanf("%d",&rows);
for(i=1; i<=rows; i++)
{
for(j=0; j<=i; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Output:
Enter the number of rows: 5 ** *** **** ***** ****** Process returned 0 (0x0) execution time : 1.865 s Press any key to continue.
References:
http://www.codeforwin.in/2015/07/star-patterns-program-in-c.html
http://www.tutorial4us.com/cpp-program/cpp-program-print-triangle-of-stars
http://www.programmingsimplified.com/c-program-print-stars-pyramid