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

solve inequality and graph 3<-5n+2n
which car has the greatest acceleration during the time interval 10 seconds to 15 seconds
PLEASE HELP ME Which of the following best summarizes the significance of the Renaissance? Artists and writers created extraordinary art and literature that com
Evaluate the related series,of each sequence -9,-16,-23,-30,-37,-44
In 1978, President Carter convinced the U.S. Senate to ratify a treaty that would turn over the __________ to Panama by the end of 1999. a. Sandinistas b. Panam
Why is anthracite a better fuel than lignite?
what is the minimum percentage of gasoline stations that had prices between $3.37 and $3.61
Which was not an issue that divided the delegates to the Constitutional Convention? A. how to count slaves for representation B. the continuation of the slave t
The process of cell division that creates sex cells in sexually reproducing organisms is called meiosis. translation. replication. mitosis.
Solve: n/4-1=n/5 .·(>▂<)·.