Ask Question
24 May, 02:54

Write an algorithm which gets a number A, if it is even, prints even, and if it is odd prints odd.

+2
Answers (1)
  1. 24 May, 03:23
    0
    The algorithm to find A is even or odd.

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

    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write an algorithm which gets a number A, if it is even, prints even, and if it is odd prints odd. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers