Phone Numbers

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

Juilian has made a program that reads in a phone number in its international form and displays what country the phone number is from. His code has a number of bugs as he is still getting used to using if statements.

Download a copy of phoneNumbers.c then find the bugs in the if statements and fix them so that program works properly.

You can find out more about how phone number country codes work from the wikipedia page.

You will see that the getchar() function is used in this program to read in digits. This function reads in a single character that the user has entered.

To run some simple automated tests:

$ 1511 autotest phoneNumbers

To run Styl-o-matic:

$ 1511 stylomatic phoneNumbers.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 wk03_phoneNumbers

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