This program correctly prints whether a number is even or odd ...
#include <stdio.h>
int main(void)
{
int n;
printf("Please enter a number:");
scanf("%d", &n);
if(n % 2 == 0)
printf("%d is even", n);
else
printf("%d is odd",n);
return 0;
}
I don't understand how n % 2
can give a meaningful result when n
is less than two. %
is the remainder operation, right? If n
is less than two, how can you divide it by two at all?