Skip to content

Latest commit

 

History

History
29 lines (18 loc) · 728 Bytes

exercise_1.md

File metadata and controls

29 lines (18 loc) · 728 Bytes

Unit 2 Practice

Exercise 1 - Count the loops

1.1

Construct a Read, Evaluate, Print, Loop (REPL) which performs the following on each iteration of the loop:

  • Increment a counter variable to keep track of the number of loops.

  • Ask the user if they would like to loop again.

  • If the user enters 'yes', repeat the loop

  • If the user enters 'no', end the loop and display the number of loops performed.

    Output:

    Again? yes/no: yes
    Again? yes/no: yes
    Again? yes/no: yes
    Again? yes/no: no
    
    The loop ran 4 times.
    

Exercise 1 solution