Help... C++ beginner code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help... C++ beginner code

I want to the output to show "Invalid Choice!" ... but when I enter "6" nothing happens ... Here is the code: cout << "You have chosen the Roman Number programing chalenge." << endl; cout << "Enter a number between 1 and 5:"; int number; cin >> number; switch (number) { case 4: cout << "The roman numerial version of 4 is: IV" << endl; break; case 1: cout << "The roman numerial version of 1 is: I" << endl; break; case 2: cout << "The roman numerial version of 2 is: II" << endl; break; case 3: cout << "The roman numerial version of 3 is: III" << endl; break; case 5: cout << "The roman numertial version of 5 is: V" << endl; break; if (number > 5) { cout << "Invalid Choice!" << endl;

23rd Mar 2017, 9:03 PM
Luke Mai
Luke Mai - avatar
1 Answer
+ 5
put this as the last case of your switch default: cout << "Invalid Choice!" << endl; break;
23rd Mar 2017, 9:10 PM
Joseph Kutloano Melvin More
Joseph Kutloano Melvin More - avatar