CS1101C Lab 2 (Odd Week)

Roman Numerals

The deadline for this lab question is Thursday 02 March 2006, 23:59:59 hours.

The name of your C program file must be called roman.c, files with any other name will not be marked.

Preliminary

Roman numerals are used frequently to indicate dates, in particular the year (for example, MMVI represents the year 2006). There are two main differences between roman and arabic numerals.

Your task for this lab assignment is to convert a number ranging from 1 to 9999 to its roman numeral equivalent.

Roman Numeral Conversion

The conversion is specified using the following cases.

The Task

Write a program roman.c that requests a year from the user. Assuming that the executable is roman, a sample run of the program is shown below. User input is denoted in bold.

$ gcc -Wall roman.c -o roman
$ roman
Enter the year : 1
Year 1 in roman numerals is I.

$ roman
Enter the year : 2006
Year 2006 in roman numerals is MMVI.

$ roman
Enter the year : 1998
Year 1998 in roman numerals is MCMXCVIII.

$ roman
Enter the year : 9999
Year 9999 in roman numerals is MMMMMMMMMCMXCIX.

$ roman
Enter the year : 9888
Year 9888 in roman numerals is MMMMMMMMMDCCCLXXXVIII.

$

Points to Note


This document, index.html, has been accessed 13 times since 25-Jun-24 11:57:13 +08. This is the 1st time it has been accessed today.

A total of 9 different hosts have accessed this document in the last 391 days; your host, 216.73.216.149, has accessed it 1 times.

If you're interested, complete statistics for this document are also available, including breakdowns by top-level domain, host name, and date.