C Program to Generate Flag of Nepal

Generating Flag of Nepal Using Stars in C Programming Language.

In this program row number is first read from user and this row number indicates number of lines in each section of flag. If row number given by user is 7 then flag will contain total of 21 lines.

Flag of Nepal C Program


#include<stdio.h>

void triangleShape(int n);
void flagPole(int n);

int main()
{
    int row;
    printf("Enter number of rows: ");
    scanf("%d", &row);
    triangleShape(row);
    triangleShape(row);
    flagPole(row);
    return 0;
}

void triangleShape(int n)
{
    int i,j;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=i;j++)
        {
            printf("* ");
        }
        printf("\n");
    }
}

void flagPole(int n)
{
    int i;
    for(i=1;i<=n;i++)
    {
        printf("*\n");
    }
}

Output of Above Program

Enter number of rows: 7

*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
*
*
*
*
*
*
*