HackerRank C++ Conditional Statements
Now use the if else condition, if the number is greater than 9 it should print the message " Greater than 9 " and if the number is between 1 to 9 then print the number in words ex if the number is 5 then program will print "five".
- #include <map>
- #include <set>
- #include <list>
- #include <cmath>
- #include <ctime>
- #include <deque>
- #include <queue>
- #include <stack>
- #include <string>
- #include <bitset>
- #include <cstdio>
- #include <limits>
- #include <vector>
- #include <climits>
- #include <cstring>
- #include <cstdlib>
- #include <fstream>
- #include <numeric>
- #include <sstream>
- #include <iostream>
- #include <algorithm>
- #include <unordered_map>
-
- using namespace std;
-
- int main()
- {
- int n;
- cin >> n;
- string num[10] = {"Greater than 9", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
-
- cin >> n;
-
- if(n > 9)
- {
- cout << num[0];
- }
- else
- {
- cout << num[n];
- }
-
- return 0;
- }