Converting numbers to Roman numerals in C++

  • Context: C/C++ 
  • Thread starter Thread starter mulabisc
  • Start date Start date
  • Tags Tags
    C++ Numbers Program
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
mulabisc
Messages
3
Reaction score
0
#include <iostream>
using namespace std;

int main()
{

int n;
n >=1;

count<< "please enter an interger number:" <<endl;
cin >> n;

if(n == 9)

count << "IX";

else if(n >=5 && n<=8)

count << "V";

else if (n == 4)

count << "IV";


else if(n >=1 && n <=3)

count << "I";




return 0;
}
 
Physics news on Phys.org
If you're going to make a list of if-statements and you need to accept numbers up to 10,000 it's going to be a long program.
 
i wil try it n post it...thanks for the advice
 
Code:
else if(n >=1 && n <=3)

cout << "I";
This will print a I for numbers 1 to 3. You may want to check on it.

You are on the right track for 1 to 9.

Keep it up for other digits, tens, hundreds, etc.