Write a program to check whether a number entered is even or odd.

This answer is restricted. Please login to view the answer of this question.

Login Now
#include <stdio.h>
int main() {
    int num;
    printf("Enter an integer: ");
    scanf("%d", &num);

    // true if num is perfectly divisible by 2
    if(num % 2 == 0)
        printf("%d is even.", num);
        printf("%d is odd.", num);
    return 0;

The output of above program is

Enter an integer: -7
-7 is odd.


If you found any type of error on the answer then please mention on the comment or report an answer or submit your new answer.
Leave your Answer:

Click here to submit your answer.

  Loading . . .