triangular star

#include <stdio.h>
char printstar(int rows);

int main()
{
    int n,row,j;
    char star='*' ;
    printf("enter 1 for triangle star\n 0 for reverse triangle star\n");
    printf("enter:");
    scanf("%d",&n);
    if(n==0)
    {
        printf("enter no of rows u want:");
        scanf("%d",&row);
        for(j=row;j>=1;j--)
        {
            printstar(j);
        }
    }
    else if (n==1)
    {
        printf("enter no of rows u want:");
        scanf("%d",&row);
        for(j=1;j<=row;j++)
        {
            printstar(j);
        }
    }
    return 0;
}

char printstar(int rows)
{
    int i,star='*';
    for(i=1;i<=rows;i++)
        {
            printf("%c",star);
           
        }
        printf("\n");
}

Comments

Popular posts from this blog

Steps taken by a compiler to execute a C program

Tokens in C

Variables and Data Types in C