Numbers to Words

This is a pair exercise and must be competed in your tutorial or lab with your partner.

Make a program called numberWords.c. This program will ask for a number with the message Please enter an integer:. For numbers between 1 and 5, display the number as a word in the message You entered number. For numbers less than 1, display the message You entered a number less than one. For numbers greater than 5, display the message You entered a number greater than five.

Some Examples

$ ./numberWords
Please enter an integer: 2
You entered two.
$ ./numberWords
Please enter an integer: 5
You entered five.
$ ./numberWords
Please enter an integer: 0
You entered a number less than one.
$ ./numberWords
Please enter an integer: 1000
You entered a number greater than five.

To run some simple automated tests:

$ 1511 autotest numberWords

To run Styl-o-matic:

$ 1511 stylomatic numberWords.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 wk02_numberWords

Or, if you are working from home, upload the relevant file(s) to the wk02_numberWords activity on Give Online.