Computer Science, asked by ashadulislam514, 1 year ago

write an algorithm to find whether a given number is odd or even

Answers

Answered by qwvilla
19

An algorithm to find whether a given number is odd or even:

  • Step 1: Start
  • Step 2: Taking input of a number say n
  • Step 3: Read the number n
  • Step 4: Check if((n%2)==1), then

                  Print n is an odd number

          Else

                 Print n is an even number

  • Step 5: End

What are odd and even numbers?

  • Odd numbers are the numbers that are not divisible by 2, it starts from 1. In other words, these numbers leave 1 as a remainder.
  • Even numbers are the numbers that are divisible by 2, it starts from 0. In other words, these numbers leave 0 as a remainder.

Answered by adventureisland
35

Even integers can always be divided into two without leaving any remaining pieces. They have a 0, 2, 4, 6, or 8 digit ending. Odd numbers are not equally divided by 2.

Algorithm to find whether a given number is odd or even :

  • Even integers can always be divided into two without leaving any remaining pieces. They have a 0, 2, 4, 6, or 8 digit ending. Odd numbers are not equally divided by 2.
  • After division by an integer, the remaining operation, percent, returns the residual. If n is even, n percent 2 == 0 will indeed be true, but if n is odd, it will also be incorrect.

ALGORITHM :

STEP 1: START

STEP 2:Receive data from a user or dynamically assign value.

STEP 3: if num percent 2 == 0. Even Integer should be printed.

STEP 4: Else,  Print an Odd Number 

STEP 5: Print an Odd Number 

STEP 6: END

Similar questions