Signup/Sign In
LAST UPDATED: JANUARY 10, 2022

C Program To Print Right Triangle Star Pattern

learn c Language

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:

Right Triangle



About the author:
I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web development. I have 10 years of diverse experience in software development. Founder @ Studytonight