Even or Odd in C
Q. Write a C program to check even or odd number.
#include <stdio.h>
#include <conio.h>
void main()
{
int n;
clrscr();
printf("Enter an integer: ");
scanf("%d", &n);
if (n%2 == 0){
printf("The number %d is Even number.",n);
}
else{
printf("The number %d is Odd number.",n);
}
getch();
}
Q. Write an algorithm to check even or odd number.
Step 1: Start
Step 2: Declare an integer variable `n`
Step 3: Prompt the user to enter an integer
Step 4: Read the integer input from the user and store it in variable `n`
Step 5: Calculate `n % 2` (remainder when `n` is divided by 2)
Step 6: - If the remainder is `0`, then
- Print "The number `n` is Even number."
- Else
- Print "The number `n` is Odd number."
Step 7: End
Quickly Find What You Are Looking For
OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.
point.com