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

How do I shift reality?
how to write aletter to your cousin who wants to go abroad for job​
How do you say "Woman, you talk to much" in Spanish?​
what was Anglo-Saxonism tied to?
Definition of faction(politics)
Could someone help with this math??!
What’s the mathematical expression for “five times x is fewer than 12”
Calculate the volume of the gas, in liters, if 1.75 mol has a pressure of 1.28 atm at a temperature of -7 ∘C
Select the correct answer from the drop-down menu, An outline helps a writer plan a writing project by -identifying the purpose of the project -preparing for re
When we place a teabag in hot water, the water takes on a brownish colour. Explain which process has taken place.