Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

dry run for the given code ?

+2 votes
asked Sep 23, 2019 by anonymous
/*explanation in brief*/
#include <stdio.h>

int main()
{
    int i, j, rows;

    /* Input rows from user */
    printf("Enter number of rows: ");
    scanf("%d", &rows);

    /* Iterate through rows */
    for(i=1; i<=rows; i++)
    {
        /* Print spaces in decreasing order of row */
        for(j=i; j<rows; j++)
        {
            printf(" ");
        }

        /* Print star in increasing order or row */
        for(j=1; j<=i; j++)
        {
            printf("*");
        }

        /* Move to next line */
        printf("\n");
    }
    
    return 0;
}

1 Answer

0 votes
answered Sep 24, 2019 by anonymous
1. User enters number of rows

2. Checks if first for condition is true. Moves to next for loop.

3. Adds whitespace until condition is false. Moves to next for loop.

4. Prints * until condition is false.

5. Prints new line

6. Repeat stages 2-6 until stage 2 is false.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...