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

kim has a scale drawing of a car with a scale of 1 in : 3 ft. what is the scale factor
30 x what will equal 100
Order the set of numbers from least to greatest.
Who were the almoravids?
If both the real interest rate and the nominal interest rate are 3 percent, then the
Write and balance the chemical equation for the reaction between carbon monoxide, co(g), and oxygen to form carbon dioxide, co2(g). use only integers (not fract
A patient is taking nicotinic acid (niacin) to treat hyperlipidemia. the patient reports a flushing sensation along with gastrointestinal irritation. the nurse
To rely solely on race to stop or detain a person would be against the rights provided in the _____________ and the fourteenth amendments.
what is the frankish kingdom
Criminal procedure refers to the methods the government can use to: