13.7k views
3 votes
Write an algorithm which gets a number A, if it is even, prints even, and if it is odd prints odd.

User El Mocoso
by
6.0k points

1 Answer

5 votes

Answer:

The algorithm to find A is even or odd.

  1. input A.
  2. Check the remainder on diving by 2 by A%2.
  3. If remainder is 1 then A is odd Print(Odd).
  4. If remainder is 0 print(Even).

Step-by-step explanation:

To check if the number is even or odd we use modulo operator(%).Which gives the remainder on dividing.So if we do this A%2 it will give the remainder that will come out on dividing the value of A by 2.

So if the remainder comes out is 1 then the number is odd and if the remainder is 0 then the number is odd.

User Inzamam Malik
by
6.9k points