jeudi 18 mars 2021

Explain me the the concept of this loop

What is the relation between j and I? What is the purpose of j, i, and x? Please take some time to explain me this whole concept.

  #include <stdio.h>
    int main() {
        int a, i, j = 1, x = 0;
        printf("Input number of lines: ");
        scanf("%d", &a);
        for(i = 1; i <= a; i++) {
            while(x < 3) {
                printf("%d ", j++);
                x++;
            }
            x = 0;
            printf("\n");
        }
        
        return 0;
    }

Aucun commentaire:

Enregistrer un commentaire