C Online Compiler
Example: C Program to Check Whether a Number is Even or Odd using Conditional Operator
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Check Whether a Number is Even or Odd using Conditional Operator #include <stdio.h> int main() { int x; printf ("Enter an integer number to check ::\n"); scanf ("%d", &x); x = x % 2 == 0 ? 1 : 0; if (x) { printf ("The input number is even.\n"); } else { printf ("The input number is odd.\n"); } return 0; }
6
Output
Clear
ADVERTISEMENTS