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

Is 12 cm greater than less than or equal to 98 mm
What is one job of RNA? A. unraveling DNA B. manufacturing nucleotides C. carrying genetic information D. giving shape to chromosomes
2 and 3/4-1/2[tex] \fra[/tex]
In Baroque art, the artists intend for the viewer to examine the _________ aspects instead of the _____________ aspects of their work.
Legislative oversight is
A kite is flying 70 feet above the ground and is attached to a string tied to a stake on the ground. The angle of elevation formed by the string and the ground
at the beginning of the reading why is odysseus recounting his most recent battle
what statement best describes the relationship between heat and temperature
write the plural possessive form of each noun for questions 1-3 1.) Friend 2.) Box 3.) House
Why was Spartan society focused on war?