Oracle interview question

see above

Interview Answer

Anonymous

7 May 2015

Question: If I gave you 0-100 inputs, print X if even, Y if div by 5, the number if anything else. Answer (there is probably a more elegant way to do this): int main() { int upperBound = 101; for(int i = 0; i < upperBound; ++i) { if(i % 2 == 0) { if(i % 5 == 0) { cout << "Y "; } else { cout << "X "; } } else { cout << i << " "; } } return 0; }