C/++/# Help with a c++ program that converts numbers 1 t0 1000

  • Thread starter mulabisc
  • Start date
#include <iostream>
using namespace std;

int main()
{

int n;
n >=1;

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

if(n == 9)

cout << "IX";

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

cout << "V";

else if (n == 4)

cout << "IV";


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

cout << "I";




return 0;
}
 

CompuChip

Science Advisor
Homework Helper
4,284
47
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.
 

Related Threads for: Help with a c++ program that converts numbers 1 t0 1000

Replies
5
Views
10K
  • Posted
Replies
5
Views
556
Replies
4
Views
2K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top