# Converting Decimal Number lying between 1 to 3999 to Roman Numerals in C++

C++Server Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

66 Lectures 5.5 hours

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

Live Demo

#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