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

For what value of x is the area of the rectangle greater than the perimeter? The base of the perimeter is x+2 The height is 7
a material that contains only one type of matter is blank
How do I solve for 6 1/3 + 5 3/10?
How do you find the derivative of y=tan(arcsin(x))y=tan(arcsin(x)) ?
Use the following statements to write a compound statement for each conjunction and disjunction. then find it's truth value. p: The square root of -64 = 8 q:
Will xenon react to nitrogen and why?
what is a lcm word problem that equals 6?
Just turn around to solve this challenge 09:009
A hypothesis that has been rigorously tested is called
Complete the square to solve for x:2x∧2-5x-3=0