All articles
c

A program to print the format - right angled star triangle

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 042

The following code shows how to write a program to print the following format.

*
**
***
****

Program

#include <stdio.h>
 
void main()
{
    int i, j;
    for (i = 1; i <= 4; i++)
    {
        for (j = 1; j <= i; j++)
        {
            printf("*");
        }
        printf("\n");
    }
 
    printf("\n");
}

Result

*
**
***
****

Comments