Wednesday, 30 August 2017

C program to print right triangle star pattern

C program to print right triangle star pattern  

Star Pattern - 5

*
**
***
****
*****
 
#include <stdio.h>

int main()
{
    int i, j, n;

    // Input number of rows from user
    printf("Enter value of n: ");
    scanf("%d", &n);

    for(i=1; i<=n; i++)
    {
        // Print i number of stars
        for(j=1; j<=i; j++)
        {
            printf("*");
        }

        // Move to next line/row
        printf("\n");
    }

    return 0;
} 

No comments:

Post a Comment