➽ Program:-

#include<iostream>

using namespace std;

int main()

    int number, rem;

    cout << "Enter a Number: ";

    cin >> number;

    cout << "Roman number is ";      

 

    while(number != 0)

    {

        if(number >= 1000)     

        {

            cout << "m";

            number -= 1000;

        }

 

        else if(number >= 900) 

        {

            cout << "cm";

            number -= 900;

        }      

 

        else if(number >= 500)

        {         

            cout << "d";

            number -= 500;

        }

 

        else if(number >= 400)

        {

            cout << "cd";

            number -= 400;

        }

 

        else if(number >= 100)

        {

            cout << "c";

            number -= 100;                      

        }

 

        else if(number >= 90)

        {

            cout << "xc";

            number -= 90;                                            

        }

 

        else if(number >= 50)

        {

            cout << "l";

            number -= 50;                                                                   

        }

 

        else if(number >= 40)

        {

            cout << "xl";         

            number -= 40;

        }

 

        else if(number >= 10)

        {

            cout << "x";

            number -= 10;         

        }

 

        else if(number >= 9)

        {

            cout << "ix";

            number -= 9;                       

        }

 

        else if(number >= 5)   

        {

            cout << "v";

            number -= 5;                                   

        }

 

        else if(number >= 4)

        {

            cout << "iv";

            number -= 4;                                                          

        }

 

        else if(number >= 1)

        {

            cout << "i";

            number -= 1;                                                                                 

        }

    }

    return 0;

}

➽ Output:-

Enter a Number: 2021
Roman number is mmxxi