Introduction to Programming

Loops


#include <stdio.h>

int main(int argc, char *argv[])
{
    int a=3, b=5, c;

    for (c=0; c<a; c++)
    {
        printf("This is the first loop!\n");
    }

    for (c=0; c<b; c++)
    {
        printf("This is the second loop!\n");
    }

    for (a=0; a<10; a++)
    {
        for (b=0; b<3; b++)
        {
            for (c=0; c<5; c++)
            {
                printf("looping %d %d %d\n", a, b, c);
            }
        }
    }

    return 0;
}

Next: Arguments

Previous: if ... then


Introduction to Programming

Home