sandyykn4143 sandyykn4143
  • 03-10-2019
  • Computers and Technology
contestada

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

Respuesta :

ExieFansler ExieFansler
  • 04-10-2019

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).

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.

Answer Link

Otras preguntas

Work out 3/4 - 1/6 Give your answer in its simplest form.
Descrierea meseriei de avocat in franceza
How many grams of Na20 are produced when 57.5g of Na reacts? 4N+O2->2Na2O
Explain the difference interactions that can take place when the beam of light hits the glass tank and then enters the water. Why does the beam of light change
David is buying a new car for $21,349.00. He plans to make a down payment of $3,000.00. If he's to make monthly payments of $352 for the next five years, what
There are 100 ducks the farmer sells 50 but then gains another 60 then he divides them by 2
how did divisions in Protestantism take place in Switzerland
What two facts can you double to find 8 x 4
What element is the basis for all living things and can combine with other elements in many ways? phosphorus
help me with this please