| Lexington High School Mathematics | Math Dept. Front Page | Student Links | Family Links |
| Introduction to C++, Kevin Kelly | Kelly Front Page | C++ Course Guide | C++ Assignments | C++ Info |
Expressions like 1st, 2nd, 3rd, 4th, 5th, 6th, ... are called ordinal numbers. Write a program where the user inputs a number, then the program prints the corresponding ordinal number. For example, if the user types 3, the program should respond with 3rd.
Your program will need to choose which suffix (st, nd, rd, th) to output, based on the input number.
Choose your own test values, sufficient to show that all the different cases work correctly.
apstring numberwithsuffix (int num)
that takes a number as the input and returns an ordinal number string as the output.
For example, numberwithsuffix(3) would return "3rd".