 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Converting Decimal Number lying between 1 to 3999 to Roman Numerals in C++
In this tutorial, we will be discussing a program to convert decimal number lying between 1 to 3999 to roman numerals.
For this we will be provided with a random integer. Our task is to convert the given number into its roman numeral equivalent.
Example
#include <bits/stdc++.h> using namespace std; //converting decimal to roman numeral int printRoman(int number){    int num[] = {1,4,5,9,10,40,50,90,100,400,500,900,1000};    string sym[] =    {"I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"};    int i=12;    while(number>0){       int div = number/num[i];       number = number%num[i];       while(div--){          cout<<sym[i];       }       i--;    } } int main(){    int number = 3949;    printRoman(number);    return 0; }  Output
MMMCMXLIX
Advertisements
 