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

The golgi complex is composed of about six flattened membranous sacs called
A cylindrical tube 14.0 cm high and 2.5 cm in diameter is used to collect blood samples. how many cubic decimeters (dm3) of blood can it hold (v of a cylinder =
If we take 1,000 canadian randomly , approximately how many of them speak french ?
Mesopotamia is a word that refers to land between two rivers; the names of the rivers are:
Please help me !!!!!
Each day, Jake donates money to the global hunger initiative according to how many lunch specials he sells. What is the constant of proportionality in money per
Answer bottom 6 algebra 1 problems please
What authority did the parliament institution have in the colonies
What mineral lies under most of the North Central Plains and the Great Plains? A.Rocks B.Gold C.Limestone D.Silver
A waist to hip ratio shows the extra weight on your hips true or false