I need help making a C++ code. I need the code to ask the user to enter a number between 1-10 and display the Roman numeral version of that number. Also I need it to have an input validation that decides how the program would handle an input below 1 or greater than 10. I have most of the code but it keeps failing I need help fixing it. #include //header file using namespace std; int main() {//main method cout << "enter a number" << endl; int n; cin >> n;//inputting the n value string arr[] = { "I","II","III","IV","V","VI","VII","VIII","IX","X" };//storing the roman numbers in a array if (n < 1 || n>10)//if n<1 && n>10 then it will print the given number is an invalid number cout << "given number is invalid number " << endl; else//is it will print the roman number of the given number cout << " the roman number for the given integer is " << arr[n - 1] << endl; }
I need help making a C++ code. I need the code to ask the user to enter a number between 1-10 and display the Roman numeral version of that number. Also I need it to have an input validation that decides how the program would handle an input below 1 or greater than 10. I have most of the code but it keeps failing I need help fixing it.
#include <iostream>//header file
using namespace std;
int main() {//main method
cout << "enter a number" << endl;
int n;
cin >> n;//inputting the n value
string arr[] = { "I","II","III","IV","V","VI","VII","VIII","IX","X" };//storing the roman numbers in a array
if (n < 1 || n>10)//if n<1 && n>10 then it will print the given number is an invalid number
cout << "given number is invalid number " << endl;
else//is it will print the roman number of the given number
cout << " the roman number for the given integer is " << arr[n - 1] << endl;
}
Step by step
Solved in 3 steps with 1 images