Solution for Exercise 11-2

ex1102

#include <stdio.h>

int main()
{
    int x;

    x=0;
    while(x<10)
    {
        puts("Get off my lawn you kids!");
        x++;
    }
    return(0);
}

Output

Get off my lawn you kids!
Get off my lawn you kids!
Get off my lawn you kids!
Get off my lawn you kids!
Get off my lawn you kids!
Get off my lawn you kids!
Get off my lawn you kids!
Get off my lawn you kids!
Get off my lawn you kids!
Get off my lawn you kids!

Notes

* The while loop's initialization statement takes place at Line 7: x = 0;

* The looping variable x must be manipulated within the while loop, lest you create an endless loop.

* The increment operator appears at Line 11.