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

Which describes a disadvantage of the sharecropping system? A.Government officials could not collect taxes on farm produce. B.Land owners were prohibited from
why did Khrushchev denounce the crimes of the stalin era in 1956
Wha it 7 1 out of 8 + 6 7 out of 4
Andy has been consuming a set number of calories and recently added an additional 100 calories in the form of a daily snack. Although he is not trying to lose w
How do people see the county of India
Use the graph; Describe the association between the year and the distance jumped for the years after 1988.
The possible solutions for earthquake
Which statement describes an example of gene therapy? A.A virus is used to transfer human DNA into a bacterial cell. B.A defective gene is replaced with a norm
How are kyanite crystals formed
one thing explorers were looking for on their voyages was bannans spices freshwater volcanoes