Loops: Demo

Variables and data types
  • Ses3Loops Source Code

    #include <stdio.h>

    #include <stdlib.h>

     

    int main(int argc, char *argv[]) {

        //for loop

        printf("for loop demo\n");

        int i;

        for (i = 0; i < 3; i++) {

            printf("%d\n", i);

        }

        printf("while loop demo\n");

        int x = 0;

        while (x < 3) {

            printf("%d\n", x);

            x++;

        }

        printf("Do while loop demo\n");

        int a = 0;

        do {

            printf("%d\n", a);

            a++;

        } while (a < 3);

        return 0;

    }