C++ converting base 10 to Roman numerals

  • Thread starter Thread starter Math Is Hard
  • Start date Start date
  • Tags Tags
    Base C++
Click For Summary
The discussion centers on converting base 10 numbers to Roman numerals using C++. The original poster struggles with implementing a loop to handle the conversion efficiently without using arrays, as they are not yet familiar with that concept. Suggestions include using functions to encapsulate repeated logic and considering a while loop for subtraction instead of division for better efficiency. Participants also discuss the importance of maintaining the correct order of Roman numeral symbols during conversion and share various coding approaches, emphasizing clarity and elegance in the code. Ultimately, the conversation highlights the challenges and strategies involved in programming this conversion task effectively.
  • #61
If you want to count more than 3999, you would use parentheses around letters as explained at http://mathworld.wolfram.com/RomanNumerals.html. You wouldn't write MMMM. 4000 would be written M(V)

Edit: Or you could add a vinculum by using 2 lines of output and an underscore.

If for some reason you want to use more than 3 M's, you can just add more M's at the end of string s.

Yes, that's how the conditional statement works.
 
Last edited:

Similar threads

  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 15 ·
Replies
15
Views
12K
Replies
7
Views
16K
  • · Replies 7 ·
Replies
7
Views
1K