Name: Arabic to Roman Numerals Converter
Roman Numeral Examples: I,V,X,C,D,M
Arabic Numeral Examples: 0,1,2,3,4,5,6,7,8,9
Description: This program converts Arabic Numerals into Roman Numerals.
As you can see in the screenshot below, you can enter any Arabic number you want. I entered number 99,999,3456, then, it displayed their corresponding Roman Numeral Format.
//Below are the Codes of the Program:
#include <iostream.h>
#include <string.h>
#include <math.h>
int main()
{
char ans, ch;
cout<< " [1] Conversion of Arabic Number to Roman Number Format\n";
do
{
cout<< " Let's test your keyboard. Type this number [1]: ";
cin>> ch;
if(ch=='1')
{
int yr, m, cm, d, c, xc, l, x, ix, v, i;
cout<< " Enter any ARABIC NUMBER you want: ";
cin>> yr;
cout<<"\n In Roman Numeral Format: ";
for(m = 1000;yr >= m; yr -= 1000)
{cout<<"M";}
for(cm = 900; yr >= cm; yr -= 900)
{cout<< "CM";}
for(d = 500;yr >= d; yr -= 500)
{cout<<"D";}
if(yr >= 400){ cout<<"CD"; yr -= 400; }
else {
for(c = 100;yr >= c; yr -= 100)
{cout<<"C";}
}
for(xc = 90; yr >= xc; yr -= 90)
{cout<< "XC";}
for(l = 50;yr >= l; yr -= 50)
{cout<<"L";}
if(yr >= 40){ cout<<"XL"; yr -= 40; }
else {
for(x = 10;yr >= x; yr -= 10)
{cout<<"X";}
}
for(ix = 9; yr >= ix; yr -= 9)
{cout<< "IX";}
for(v = 5;yr >= v; yr -= 5)
{cout<<"V";}
if(yr >= 4){ cout<<"IV"; yr -= 4; }
else {
for(i = 1;yr >= i; yr -= 1)
{cout<<"I";}
}
}
else
{
cout<< " Invalid input number!\n";
cout<< endl;
}
cout<< "\n\n Try Again?[y/n]: ";
cin>> ans;
}while(ans=='y'||ans=='Y');
cout<< " Thank You!\n";
cin.get();
cin.get();
return 0;
}
#include <iostream.h>
#include <string.h>
#include <math.h>
int main()
{
char ans, ch;
cout<< " [1] Conversion of Arabic Number to Roman Number Format\n";
do
{
cout<< " Let's test your keyboard. Type this number [1]: ";
cin>> ch;
if(ch=='1')
{
int yr, m, cm, d, c, xc, l, x, ix, v, i;
cout<< " Enter any ARABIC NUMBER you want: ";
cin>> yr;
cout<<"\n In Roman Numeral Format: ";
for(m = 1000;yr >= m; yr -= 1000)
{cout<<"M";}
for(cm = 900; yr >= cm; yr -= 900)
{cout<< "CM";}
for(d = 500;yr >= d; yr -= 500)
{cout<<"D";}
if(yr >= 400){ cout<<"CD"; yr -= 400; }
else {
for(c = 100;yr >= c; yr -= 100)
{cout<<"C";}
}
for(xc = 90; yr >= xc; yr -= 90)
{cout<< "XC";}
for(l = 50;yr >= l; yr -= 50)
{cout<<"L";}
if(yr >= 40){ cout<<"XL"; yr -= 40; }
else {
for(x = 10;yr >= x; yr -= 10)
{cout<<"X";}
}
for(ix = 9; yr >= ix; yr -= 9)
{cout<< "IX";}
for(v = 5;yr >= v; yr -= 5)
{cout<<"V";}
if(yr >= 4){ cout<<"IV"; yr -= 4; }
else {
for(i = 1;yr >= i; yr -= 1)
{cout<<"I";}
}
}
else
{
cout<< " Invalid input number!\n";
cout<< endl;
}
cout<< "\n\n Try Again?[y/n]: ";
cin>> ans;
}while(ans=='y'||ans=='Y');
cout<< " Thank You!\n";
cin.get();
cin.get();
return 0;
}