Sort 3 Numbers

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

Write a program in a file called sort3.c to read in 3 whole numbers with the message Enter 3 numbers: in the form n n n and print them out in ascending (non decreasing) order, one per line.

Some Examples

Enter 3 numbers: 8 5 9
5
8
9
Enter 3 numbers: 0 3 5
0
3
5
Enter 3 numbers: -1 -2 -3
-3
-2
-1
Enter 3 numbers: 9 8 9
8
9
9
Enter 3 numbers: 3 2 1
1
2
3

Note to everyone: Computers are quite literal and pedantic. Do make sure your output EXACTLY matches this output above.

Note to experienced programmers: only use C syntax that we have covered in lectures. Use if statements (but not loops, recursion, arrays or C library sorting functions etc.)

To run some simple automated tests:

$ 1511 autotest sort3Numbers

To run Styl-o-matic:

$ 1511 stylomatic sort3.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_sort3Numbers

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