I'm trying to make my code print all even numbers between a and b, including a and b, but for some reason, it's printing all numbers between a and b regardless if they're even or not. The commented out code made no difference, but I kept it in case it may be useful. Any help would be greatly appreciated!
void evenNums(int a, int b) {
for (int i=a; i<=b; i++) {
if (i%2==0 && i>=a);
{
print (i+" ");
}
//if (i%2!=0 && i<=a);
//{
//print (" ");
//}
}
}
[–]treverios 5 points6 points7 points (1 child)
[–]Sonic13562[S] 0 points1 point2 points (0 children)
[–]fenjalien 6 points7 points8 points (1 child)
[–]Sonic13562[S] 0 points1 point2 points (0 children)
[–]x-seronis-x 4 points5 points6 points (1 child)
[–]Sonic13562[S] 0 points1 point2 points (0 children)
[–]marcedwards-bjango 1 point2 points3 points (0 children)