Some questions on for loops

  1. What is the output from the following loops?

    1. for (i=3; i>=1; i--) printf("%d\n", i);
      
    2. for (i=0; i<=3; i++) printf("%d\n", i);
      

  2. What is the while loop equivalent to each of the above loops?

  3. Put each of these examples, including the while loop equivalents, into a program, compile and run them. Make sure they behave identically.
Answers to these questions.


Back to the notes on for loops.