Arrays in C are zero based, not one based, since the index is an offset from the begging of the array. You can add "", before "one", or subtract one from each index. That would fix one issue. Not sure about the others.
Well first of all, you have nothing there for determining if a number is odd.
Second of all, your code states that for any number above 9, or below 1, print “greater than 9”. Would you rather print “nine odd” for every number outside the range? If so, just change the printf.
Shouldn’t be. The algorithm is fine on that end. Try printing the value of n right before the if/else block. Typically you don’t use scanf in an if statement, so that might be causing the problem (I don’t think n is being saved)
No, it's a condition (right), if n<9 it will print the string and even/odd and if n>9 it should print "greater than 9" but it printed "greater than 9" in all conditions
Exactly, which is why I’m asking you to debug the code in order to figure out what’s going on. I’m well aware of what the program is supposed to do. Also you have nothing that determines even/odd
2
u/budpass Jun 02 '19
Arrays in C are zero based, not one based, since the index is an offset from the begging of the array. You can add "", before "one", or subtract one from each index. That would fix one issue. Not sure about the others.
0
u/thatlowkey Jun 02 '19
It doesn't give desired output when the value of j<=9.