#include<iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter number to display equivalent roman numeral\n";
cin>>n;
for (;n>=1000;n-=1000)
cout<<"M";
for (;n>=900;n-=900)
cout<<"CM";
for (;n>=500;n-=500)
cout<<"D";
for (;n>=400;n-=400)
cout<<"CD";
for (;n>=100;n-=100)
cout<<"C";
for (;n>=90;n-=90)
cout<<"XC";
for (;n>=50;n-=50)
cout<<"L";
for (;n>=40;n-=40)
cout<<"XL";
for (;n>=10;n-=10)
cout<<"X";
for (;n>=9;n-=9)
cout<<"IX";
for (;n>=5;n-=5)
cout<<"V";
for (;n>=4;n-=4)
cout<<"IV";
for (;n>=1;n-=1)
cout<<"I";
return 0;
}
Do visit
http://facebook.com/csedevgroup
http://devendradora.blogspot.in/
http://computersciencedora.blogspot.in/
using namespace std;
int main()
{
int n;
cout<<"Enter number to display equivalent roman numeral\n";
cin>>n;
for (;n>=1000;n-=1000)
cout<<"M";
for (;n>=900;n-=900)
cout<<"CM";
for (;n>=500;n-=500)
cout<<"D";
for (;n>=400;n-=400)
cout<<"CD";
for (;n>=100;n-=100)
cout<<"C";
for (;n>=90;n-=90)
cout<<"XC";
for (;n>=50;n-=50)
cout<<"L";
for (;n>=40;n-=40)
cout<<"XL";
for (;n>=10;n-=10)
cout<<"X";
for (;n>=9;n-=9)
cout<<"IX";
for (;n>=5;n-=5)
cout<<"V";
for (;n>=4;n-=4)
cout<<"IV";
for (;n>=1;n-=1)
cout<<"I";
return 0;
}
Do visit
http://facebook.com/csedevgroup
http://devendradora.blogspot.in/
http://computersciencedora.blogspot.in/