printing star with iteration

 #include <stdio.h>

void star(int a);
int main()
{
    int a;
    printf("Enter how many rows you want to print:\n");
    scanf("%d",&a);
    star(a);

    return 0;
}
void star(int a)
{

    for (int i = 1; i <= a; i++)
    {
        for (int j = 0; j < (2 * i - 1); j++)

        {
            printf("*");
        }
        printf("\n");
    }
}

Comments

Popular posts from this blog

comparing 2 dates using structures

free dynamic memory allocation

prime number