Sunday, 11 June 2017

How to Print Star in C ?



#include<stdio.h>
#include<conio.h>

main()
{
    int n, c, k, space;

    printf("Enter number of rows\n");
    scanf("%d",&n);

    space = n;

    for ( k = 1 ; k <= n ; k++ )
    {
        for ( c = 1 ; c < space ; c++ )
            printf(" ");

        space--;

        for( c = 1 ; c <= k ; c++ )
            printf("*");

        printf("\n");
    }

    return 0;
}

0 comments:

Post a Comment