#include <stdio.h>
int main()
{
int a,b,c,d;
printf("Enter the rows upto which U want to print triangle star pattern\n");
scanf("%d",&a);
for(d=1; d<=a; ++d, b=0)
{
for(c=1; c<=a-d; ++c)
{
printf(" ");
}
while(b != 2*d-1)
{
printf("* ");
++b;
}
printf("\n");
}
return 0;
}
Output:
Enter the rows upto which U want to print triangle star pattern
4
*
* * *
* * * * *
* * * * * * *
.