Solution for Exercise 11-1

ex1101

#include <stdio.h>

int main()
{
    int x;

    for(x=0;x<10;x++)
        puts("Get off my lawn you kids!");
    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

* You don't have to use the variable x as I did; any int variable would do.

* The ++ increment operator appears at Line 7. The for statement is very similar to the for loop example shown in the book, though here you're repeating the loop ten times, not 100.

* The curly brackets in the for loop (around the puts() statement) are optional. I've omitted them above.