Q:

Even or odd program in C

0

Even or odd program in C

C programs to check odd or even using different methods. In the decimal number system, even numbers are exactly divisible by two while odd numbers are not. We can use the modulus operator '%' which returns the remainder, for example, 4%3 = 1 (remainder when four is divided by three).

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>
int main()
{
  int n;

  printf("Enter an integer\n");
  scanf("%d", &n);

  if (n%2 == 0)
    printf("Even\n");
  else
    printf("Odd\n");

  return 0;
}

output:

Enter an integer

2

Even

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now