C/Even Or Odd.c

27 lines
358 B
C
Raw Permalink Normal View History

2024-05-13 18:09:46 +02:00
#include <stdio.h>
#include <stdlib.h>
int main() {
int n; /* Number */
/* Prompt the user */
printf("Enter an integer: ");
scanf("%d", &n);
/* Determin whether or not the number is odd */
if (n / 2 != n / 2.0) /* Should have used remainder */
printf("%d is odd.\n", n);
else {
printf("%d is not odd.\n", n);
exit(1);
}
return 0;
}