C Online Compiler
Example: Check Even or Odd Using Modulo in C
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Check Even or Odd Using Modulo #include <stdio.h> int main() { int num; // Step 1: Prompt the user to enter a number printf("Enter an integer: "); // Step 2: Read the integer input from the user scanf("%d", &num); // Step 3: Check if the number is even or odd using the modulo operator if (num % 2 == 0) { printf("%d is an even number.\n", num); } else { printf("%d is an odd number.\n", num); } return 0; }
Output
Clear
ADVERTISEMENTS