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

To make curtains for a living room window for a customer, you will need three pieces of fabric in the following lengths: 3 feet, 3 feet, and 5 feet. What is th
what are the steps to evaporation but without heat just evaporation steps to follow
what are the steps to evaporation but without heat just evaporation steps to follow
You begin solving the equation 4 – 5x = 59 by subtracting 4 from both sides. Which is the best choice for Step 2?
What kinds of activities made up the early economies of the North American colonies?
A man exchanged a dollar bill for change and received 7 coins, none of which were half dollars. How many of these coins were dimes?
Force and Motion: Force changes _________.
3x-150=1778. Help me please I need help bad
what does diametor mean?
The line with equation ax+by=20 passes through the points(-2,10) and (1,5)find a and b