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

snake game Version-2 (using random number)

allocating dynamic memory using calloc

store a table in dynamic array and then change the size of array dynamically to store more numbers