Countdown 2
This is a warmup exercise.
It is not compulsory, and may be
completed individually or with your lab partner.
In this exercise you will use a loop to print a countdown from a user inputted number to 0.
Start by copying your countdown.c
file into a file called countdown2.c
:
$ cp countdown.c countdown2.c
Now open countdown2.c
and edit it so that it prompts the user to enter a positive integer and
then prints a countdown from that number until 0.
Some Examples
$ ./countdown2 Enter a positive integer: 10 10 9 8 7 6 5 4 3 2 1 0
$ ./countdown2 Enter a positive integer: 5 5 4 3 2 1 0
To run some simple automated tests:
$ 1511 autotest countdown2
To run Styl-o-matic:
$ 1511 stylomatic countdown2.c Looks good!
You’ll get advice if you need to make changes to your code.
Submit your work with the give command, like so:
$ give cs1511 wk04_countdown2
Or, if you are working from home, upload the relevant file(s) to the wk04_countdown2 activity on Give Online.