haseeblisl23 haseeblisl23
  • 19-08-2020
  • Computers and Technology
contestada

Write a program that could find whether the number entered through keyboard is odd or even the program should keep on taking the value till the user ends.

Respuesta :

tonb
tonb tonb
  • 19-08-2020

Answer:

using namespace std;

int main() {

int number;

while (1) {

 cout << "Enter a number: ";

 cin >> number;

 cout << number << " is " << ((number % 2) ? "odd" : "even") << endl;

};

return 0;

}

Explanation:

This is a c++ version. Let me know if you need other languages.

The (number % 2) is the essence of the program. It returns 0 for even numbers, and 1 for odd numbers (the remainder after division by 2).

Answer Link

Otras preguntas

A. 530 ft^2 B. 500 ft^2 C. 470 ft^2 D. 450 ft^2
Simplify 4 to the power of 2 and 4 to the power of 8
Most rules and tapes are marked in increments of _______ inches to help lay out joists, studs, and rafters. A. 8 and 10 B. 26 C. 30 D. 12 and 16
What is a limitation of using a chemical formula, such as C6H1206, to represent a compound? The chemical formula does not show the types of elements that make u
Which is TRUE about the Monroe Doctrine?​
which animal is a producer in this ecosystem
Using the properties of equality, find the value of x in the equation below. 4x(2 + 8) = -8 Type your answer as a fraction so that you give the exact answer n
What is the meaning of 'aesthetic'?
According to Homer's Iliad, which Greek god was Helen of Troy's father? A. Apollo B. Poseidon C. Zeus D. Hades
I need help please.!