For loop in C++


In my IDE my code working well but it’s keep showing wrong answer.
Here is my code:

#include <iostream>

int main()
{
using namespace std;

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

Original question link in hackerrank.
Can you please tell me what’s going on with my code?

You need to run the second loop in the interval [a+1, b] (having already traversed [a, 9] in the first loop). Start ‘i’ with 10 and increment it till ‘b’ (i <= b).

1 Like

Close. You want to start at 10 and increase to b.

2 Likes

To be real, i found myself so dumb now :disappointed: