Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Mar 16, 2009 #1
    #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;
    }
     
  2. jcsd
  3. Mar 16, 2009 #2

    CompuChip

    User Avatar
    Science Advisor
    Homework Helper

    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.
     
  4. Mar 17, 2009 #3
    i wil try it n post it...thanks for the advice
     
  5. Mar 17, 2009 #4
    Code (Text):
    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Help with a c++ program that converts numbers 1 t0 1000
  1. C program help (Replies: 3)

  2. Help in C programming (Replies: 1)

Loading...