In this HackerRank For Loop problem in c++, we need to develop a program in which we have given two positive integers a and b. for each integer n in the inclusive interval [a,b] if the value of n is less than 9 then print the English representation o it in the lowercase and if the value of n is greater than 9 and even then print even else print odd.

HackerRank For Loop in C++ problem solution

HackerRank For Loop in C++ problem solution

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {

    int a, b;
    string represent[10] = {"zero", "one", "two", "three", "four",\
    	"five", "six", "seven", "eight", "nine"};
    cin >> a >> b;
    for(int i = a; i <= b; i++) {
        
        if(i > 9) {
            if(i % 2 == 0)
                cout << "even\n";
            else cout << "odd\n";
        }
        else {
            cout << represent[i]<<endl;
        }
    }
    return 0;
}