WAP in C to check whether the number is even or odd using if else

WAP in C to check whether the number is even or odd using if else

Write a program in C to check whether the entered number is even or odd using the if-else statement.

Also, check even-odd using switch case and ternary operator or conditional operator.

A number is even if it is divisible by 2.

#include<stdio.h>

int main() {
  int n;
  printf("Enter any number:\n");
  scanf("%d",&n);
  if(n%2==0)
              printf("%d is even number",n);
  else
              printf("%d is odd number",n);
  return 0;
}

Output:

even odd output
even odd output
Loading...

Share this post