LAST UPDATED: JANUARY 10, 2022
C Program To Print Right Triangle Star Pattern
Logic To Print The Right Triangle Star Pattern:
- Get the input from the user to print the right triangle star pattern
- Create an outer loop from 1 to x, with condition i=1; i<=x; i++
- Create an inner loop from 1 to i, with condition j=1; j<=i; j++
- Print the stars within the inner loop, Print the newline after every row.
C Program To Print The Right Triangle Star Pattern:
#include <stdio.h>
int main()
{
int i, j, n;
/* Code Block To Get The Input from the user */
printf("Enter The Number Of Rows To Print Right Triangle Star Pattern: ");
scanf("%d", &n);
for(i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Output: