mahlobogoanegontse mahlobogoanegontse
  • 02-05-2022
  • Computers and Technology
contestada

How to write a C++ program that lets the user guess if a randomly generated integer is even or odd then the computer lets them know if they are correct or incorrect

Respuesta :

mohammedtom32 mohammedtom32
  • 02-05-2022

#include <iostream>

using namespace std;

int main() {

 string input;

 string rand_type;

int number=rand()%100+1; //number between 1 and 100

if ( number % 2 == 0)

   rand_type= "even";

 else

  rand_type="odd";

 cout << "your guess: ";

 cin >> input;

 if ( input== rand_type)

   cout << "correct.\n";

else

   cout << "incorrect.\n";

 return 0;

}

Answer Link

Otras preguntas

what are rod-shaped and spore-forming bacteria known as?
I need help with the question above in the picture
52.85 - 9.09 = what rounded to the nearest one
Geometry help , only answer if your sure please. The question is in the attached
....was a major issue after the American revolution and it placed a burden on the new nation
Walkway Over the Hudson; a bridge that crosses the Hudson River in Poughkeepsie is 2.063 kilometers. Anping Bridge, which was built 850 years ago, is 2.07 kilo
Help........ help...... help!!!!!!
The cost to manufacture t shirts can be represented by the function c(x)=10.5x complete the following statement about the function Part A: if a club needs 8 t-s
Can the president introduce ratify or veto a constitutional amendment?
To what extent did the British honor the Treaty of 1783 which stated they recognized the United States and its new boundaries? What does this foreshadow?