Question

(IN C LANGUAGE) 4.33 (Roman-Numeral Equivalent of Decimal Values) Write a program that prints a table...

(IN C LANGUAGE)

4.33 (Roman-Numeral Equivalent of Decimal Values) Write a program that prints a table of all
the Roman-numeral equivalents of the decimal numbers in the range 1 to 100.

Decimal→→Roman↵
-------→→-----↵
1→→I↵
2→→II↵
3→→III↵
4→→IV↵
5→→V↵
6→→VI↵
7→→VII↵
8→→VIII↵
9→→IX↵
10→→X↵
11→→XI↵
12→→XII↵
13→→XIII↵
14→→XIV↵
15→→XV↵
16→→XVI↵
17→→XVII↵
18→→XVIII↵
19→→XIX↵
20→→XX↵
21→→XXI↵
22→→XXII↵
23→→XXIII↵
24→→XXIV↵
25→→XXV↵
26→→XXVI↵
27→→XXVII↵
28→→XXVIII↵
29→→XXIX↵
30→→XXX↵
31→→XXXI↵
32→→XXXII↵
33→→XXXIII↵
34→→XXXIV↵
35→→XXXV↵
36→→XXXVI↵
37→→XXXVII↵
38→→XXXVIII↵
39→→XXXIX↵
40→→XL↵
41→→XLI↵
42→→XLII↵
43→→XLIII↵
44→→XLIV↵
45→→XLV↵
46→→XLVI↵
47→→XLVII↵
48→→XLVIII↵
49→→XLIX↵
50→→L↵
51→→LI↵
52→→LII↵
53→→LIII↵
54→→LIV↵
55→→LV↵
56→→LVI↵
57→→LVII↵
58→→LVIII↵
59→→LIX↵
60→→LX↵
61→→LXI↵
62→→LXII↵
63→→LXIII↵
64→→LXIV↵
65→→LXV↵
66→→LXVI↵
67→→LXVII↵
68→→LXVIII↵
69→→LXIX↵
70→→LXX↵
71→→LXXI↵
72→→LXXII↵
73→→LXXIII↵
74→→LXXIV↵
75→→LXXV↵
76→→LXXVI↵
77→→LXXVII↵
78→→LXXVIII↵
79→→LXXIX↵
80→→LXXX↵
81→→LXXXI↵
82→→LXXXII↵
83→→LXXXIII↵
84→→LXXXIV↵
85→→LXXXV↵
86→→LXXXVI↵
87→→LXXXVII↵
88→→LXXXVIII↵
89→→LXXXIX↵
90→→XC↵
91→→XCI↵
92→→XCII↵
93→→XCIII↵
94→→XCIV↵
95→→XCV↵
96→→XCVI↵
97→→XCVII↵
98→→XCVIII↵
99→→XCIX↵
100→→C↵
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is your code: -

#include

#include

#include

char romChars[7] = { 'I','V','X','L','C','D','M'};

int roman(int input, int romCharsNo, char normal)

{

int i;

if (input < 4 && normal == 'y')

for (i = 1; i <= input; i++) printf("%c", romChars[romCharsNo]);

else if (input == 4 && normal == 'y')

printf("%c%c",romChars[romCharsNo], romChars[romCharsNo+1]);

else if (input > 4 && input < 9 && normal == 'y')

{

printf("%c", romChars[romCharsNo+1]);

for (i = 1; i <= input - 5; i++) printf("%c", romChars[romCharsNo]);

}

else if (input == 9 && normal == 'y')

printf("%c%c", romChars[romCharsNo], romChars[romCharsNo + 2]);

else

for (i = 1; i <= input; i++) printf("%c", romChars[romCharsNo]);

}

void printRoman(int number)

{

roman(number / 1000, 6, 'n');

roman((number % 1000) / 100, 4, 'y');

roman((number % 100) / 10, 2, 'y');

roman((number % 10), 0, 'y');

}

int main()

{

int i;

for (i = 1; i <= 100; i++) {

printf("%d ",i);

printRoman(i);

printf("\n");

}

printf("\n\n Press any key to EXIT...");

getch();

puts("");

}

Output

1 I
2 II
3 III
4 IV
5 V
6 VI
7 VII
8 VIII
9 IX
10 X
11 XI
12 XII
13 XIII
14 XIV
15 XV
16 XVI
17 XVII
18 XVIII
19 XIX
20 XX
21 XXI
22 XXII
23 XXIII
24 XXIV
25 XXV
26 XXVI
27 XXVII
28 XXVIII
29 XXIX
30 XXX
31 XXXI
32 XXXII
33 XXXIII
34 XXXIV
35 XXXV
36 XXXVI
37 XXXVII
38 XXXVIII
39 XXXIX
40 XL
41 XLI
42 XLII
43 XLIII
44 XLIV
45 XLV
46 XLVI
47 XLVII
48 XLVIII
49 XLIX
50 L
51 LI
52 LII
53 LIII
54 LIV
55 LV
56 LVI
57 LVII
58 LVIII
59 LIX
60 LX
61 LXI
62 LXII
63 LXIII
64 LXIV
65 LXV
66 LXVI
67 LXVII
68 LXVIII
69 LXIX
70 LXX
71 LXXI
72 LXXII
73 LXXIII
74 LXXIV
75 LXXV
76 LXXVI
77 LXXVII
78 LXXVIII
79 LXXIX
80 LXXX
81 LXXXI
82 LXXXII
83 LXXXIII
84 LXXXIV
85 LXXXV
86 LXXXVI
87 LXXXVII
88 LXXXVIII
89 LXXXIX
90 XC
91 XCI
92 XCII
93 XCIII
94 XCIV
95 XCV
96 XCVI
97 XCVII
98 XCVIII
99 XCIX
100 C


Press any key to EXIT...

Add a comment
Know the answer?
Add Answer to:
(IN C LANGUAGE) 4.33 (Roman-Numeral Equivalent of Decimal Values) Write a program that prints a table...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python program (question2.py) that reads from a file called “input.txt” numbers in [1,39] separated...

    Write a Python program (question2.py) that reads from a file called “input.txt” numbers in [1,39] separated in by commas. The numbers are in [1-99]. The program will then convert each number to a possible Roman Numeral equivalent, and print it on the screen. Remember, I is 1, V is 5, X is 10 For example, if the input is: 23, 11 the output is: XXIII, XI. ROMAN NUMERALS CHART 1 TO 100 69 LXIX 11 2 11 3 III 4...

  • 5. (4 points) Let x1 [n] be a discrete-time signal defined as 21 [n] = 2e-n/4u[n],...

    5. (4 points) Let x1 [n] be a discrete-time signal defined as 21 [n] = 2e-n/4u[n], n e Z, and u[n] is the unit step sequence. Mark all of the true statements. (xv) x1[-n] = 2er/4uſ-n]. (xvi) O x1[n] is real valued. (xvii) O x1[n] is neither purely odd nor purely even, but it is periodic. (xviii) O x1[-n] = -2er/4u[-n]. 6. (4 points) Similarly, 22[n] = 2e-4nu[n], n e Z. Mark all of the true statements. (xix) O Pæ{rz[n]...

  • i. What is the difference between sample and population? ii. What is the difference between statistic...

    i. What is the difference between sample and population? ii. What is the difference between statistic and parameter? iii. What is the difference between descriptive statistics and statistical inference? iv. Categorical random variable contrast with numerical random variable. v. Compare discrete data from continuous data. saw. Detail the difference between nominal and ordinal scale. vii. Detail the difference between interval and ratio scale. viii. Explain the main reasons for obtaining data. ix. What is the difference between probabilistic and non-probabilistic...

  • for future views please dont use it for spring 2020 Write a Perl program to accomplish...

    for future views please dont use it for spring 2020 Write a Perl program to accomplish each of the following on the file solar.txt (see link at the class homepage) 1. Print all records that do not list a discoverer in the eighth field. 2. Print every record after erasing the second field. Note: It would be better to say "print every record" omitting the second field . 3. Print the records for satellites that have negative orbital periods. (A...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT