Hello,
I am in a C programming class, and my instructor wants us to write a program that will count from 1 to 100, and print out the roman numeral equivalent to each number.
The exact wording of the question:
Write a program that prints a table of all the Roman numeral eqivalents of the decimal numbers in the range of 1 to 100
I don't even know where to start.
the chart should look like
Number Roman Numeral
----------------------------------------------------------------
1 I
2 II
I can get the chart to print by hard coding
Code:int main (void) { int rom; printf ("Decimal Roman Numeral\n"); printf ("-----------------------------\n"); for (rom = 0; rom <= 100; rom= rom +1) { if (rom >= 1 && rom < 4) { if (rom == 1) printf ("%d I\n\n", rom); else if (rom == 2) printf ("%d II\n\n", rom); else if (rom == 3) printf ("%d III\n\n", rom); }//end if statment else if (rom >=4 && rom < 5) printf ("%d IV\n\n", rom); else if (rom >= 5 && rom <= 9) { if (rom == 5) printf ("%d V\n\n", rom); else if (rom == 6) printf ("%d VI\n\n", rom); else if (rom == 7) printf ("%d VII\n\n", rom); else if (rom == 8) printf ("%d VIII\n\n", rom); else if (rom == 9) printf ("%d IX\n\n", rom); }//end if statment }// end for printf ("\n\n"); return 0; }
I am just afraid that this is too much hard coding for her. Is there an easier way to achieve that same results?