Algorithm and Flowchart to find Whether a Number is Even or Odd

[135488 views]


What is an Even Number?

An even number is an integer number which is exactly divisible by 2.
Example: 0, 6, 8, 46, 168

What is an Odd Number?

An odd number is an integer which is not exactly divisible by 2.
Example: 1, 9, 13, 19, 51, 101

Now if you understood the definitions of Odd and Even Number properly you can easily come to a conclusion that if a number is exactly divisible by 2, then the number is considered as an even number else the number will be considered as an odd number. So now lets see the Flowchart and Pseudocode for better understanding.

Flowchart to Find Whether a Number is Even or Odd


Flowchart to Find whether a Number is Even or Odd
Remove WaterMark from Above Flowchart

Pseudocode to Find Whether a Number is Even or Odd


READ number remainder=number%2 IF remainder==0 WRITE "Even Number" ELSE WRITE "Odd Number" ENDIF

The first step in the algorithm is taking a number as an input from User. Let's say user enters value 6. So 6 will be stored inside variable "number".
Now the next step in algorithm (i.e number%2==0), in this step (number%2) returns the remainder after dividing number by 2.
[Note: Here % is known as modulus, which is an operator that returns remainder value after division]
Now the next step (i.e. remainder==0) simply checks if the remainder value is equal to 0 or not.
So if the remainder is 0, then the number is said to be Even number else it is said to be an Odd Number.

If the User Inputs 6, then
number=6
Remainder=number%2
i.e Remainder=6%2
Remainder=0
As Remainder is 0, 6 is an Even Number


C Program For Even or Odd:

#include <stdio.h> #include <stdlib.h> int main() { int num=54643; /*enter any number */    printf ("enter a num : \n");    scanf("%d",&num);     if( num%2==0)         printf ("%d is a even",num );     else         {printf ("%d is a odd",num );     }     return 0; }

Python Program to find if Number is Even or Odd:

num = int(input("Enter a number: ")) if (num % 2) == 0:     print("{0} is Even".format(num)) else:     print("{0} is Odd".format(num))

Java Program to check if a Number is Even or Odd:

import java.util.*; public class Program {     public static void main(String[] args) {         Scanner ss= new Scanner(System.in);         System.out.println("Enter the number you want to check");         int num=ss.nextInt();                 if(num%2==0)         {             System.out.println("Entered number is EVEN");         }         else         {             System.out.println("Entered number is ODD");         }     } }
        

Having Difficulty understanding above Algorithm and Flowchart? Buy Our Notes



Are You Good enough in Algorithms? Test your Skills


Comments

9 comment
  • Manoj r b

    Please send sms (9731568158) any links or website about an "ARRAY" in C program i Don't no about pls ?? send me??????

  • hachalu hirpa

    Can you help me in preparing such flowcharts. I will share the topic with you.

  • getahunasrat

    Nice

  • Sumit

    Thanks

  • Christina

    Your Notes was very helpful for understanding concepts

  • Komal Kumar.

    Ty alot

  • Binitathapa

    Thanks

  • Ruvin

    It was quite helpful thank you...

  • Darvin dobariya

    To



Search
Recommended Deals End in










Recommended Quiz
Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Search Tags

    Flowchart for Odd and Even

    Algorithm for Even and Odd

    Find if a number is Even or Odd Algorithm

    Algorithm to check if number is odd or even