We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int main() {
// Complete the code.
string a[9] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
// Declare the start number and end number
int start, end;
cin >> start >> end;
// Declare a loop for with n
for(int n = start; n <= end; n++){
if (1 <= n && n <= 9){
cout << a[n-1] << endl;
} else if(n > 9){
if (n % 2 == 0){
cout << "even" << endl;
} else{
cout << "odd" << endl;
}
}
}
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
For Loop
You are viewing a single comment's thread. Return to all comments →
include
include
using namespace std;
int main() { // Complete the code. string a[9] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; // Declare the start number and end number int start, end; cin >> start >> end; // Declare a loop for with n for(int n = start; n <= end; n++){ if (1 <= n && n <= 9){ cout << a[n-1] << endl; } else if(n > 9){ if (n % 2 == 0){ cout << "even" << endl; } else{ cout << "odd" << endl; } } }
}