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 is the name of the sugar acid produced when d-ribose is oxidized?
The practice of breaking unjust laws in protest or otherwise violating the public order for a political purpose is best described as
Describe the conversation between mr ewell and atticus at the courthouse
identify the expression that is equivalent to cot x/ csc x -1
Researcher who established that facial expression for at least the six basic emotions
what is 1.18 repeating as a fraction
Proteins can move, twist and even walk, how?
How do you think it is possible to create over 100 000 different proteins from just 20 amino acids?
1.2 divided by .3 in the model
Jessie is completing a mental rotation experiment. her reaction time will be fastest when the objects are rotated: 120 degrees. 180 degrees. 240 degrees. 60 deg