Problem: Conditional Statements
Link to the Challenge:
Problem StatementSource Code
#include <iostream>
using namespace std;
int input;
int main() {
cin >> input;
if (input == 1) {
cout << "one";
} else if (input == 2) {
cout << "two";
} else if (input == 3) {
cout << "three";
} else if (input == 4) {
cout << "four";
} else if (input == 5) {
cout << "five";
} else if (input == 6) {
cout << "six";
} else if (input == 7) {
cout << "seven";
} else if (input == 8) {
cout << "eight";
} else if (input == 9) {
cout << "nine";
} else {
cout << "Greater than 9";
}
return 0;
}
Demonstration
8
eight
44
Greater than 9