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.

how to read logic / looping from this sourcode

0 votes
asked May 13, 2020 by Satriadi Lumban Gaol (120 points) 1 flag
#include <stdio.h>

int main()
{
    int x,y;
    for(x=0; x<9; x++){
        for(y=0; y<9; y++){
            if(x==0){
                printf("*");
            }else if(x==8){
                printf("*");
            }else if(y==0){
                printf("*");
            }else if(y==8){
                printf("*");
            }else if(x==4){
                printf("*");
            }else{
                printf(" ");
            }
        }
        printf("\n");
    }

    return 0;
}

1 Answer

0 votes
answered May 15, 2020 by LiOS (6,160 points)
Flow of code goes:

- Check first for loop, if true, move on

- Check second for loop, if true, process all the if, elseif, else statements

- Goes back to second for loop. Until second for loop is false, will repeat stage 2.

- When second for loop is false. Go back to first for loop, increment and check if true, if so repeat... until first for loop 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.
...