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

Is the sequence 5,9,15———-an arithmetic?
Refers to the way we conduct ourselves
How is Hyacinthus injured?
What is the value of the sine of
Which musical form is an example of Renaissance choral music sung in church?
If ∠Q = 44°, then m = 44°. True False
Rectangle ABCD is similar to rectangle RSTU . What is the scale factor of a dilation from ABCD to RSTU ? Enter your answer in the box.
what is a word that is stronger than "beautiful"
the strength of the economy depends on the balance pf production and consumption of goods and consumption of goods and services
Why is it important to include a descriptive subject heading? It helps in sorting the topics. It helps the recipient see its importance. E-mail programs won’t a