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

if the following graph represents the decay of strontium-90 in an igneous rock, what event occurred at 0 years on the horizontal axis ?
What does regions mean
Casey sells half of his video games. The next day he buys 3 more. He now has 27. How many video games did Casey have at the beginning?
which of the following equations is an example of inverse variation between the variables x and y? A. y=x/3 B. y=3/x C. y= x+3 D. y= 3x
Which diet consists of whole-grain cereals and vegetables, a small amount of fish, and no other meats or fruits? a. vegetarian b. macrobiotic c. ovo-vegetari
Who was martin luther?
Show the tens fact you used. Write the difference. 13-7= 10- =
Question 2: During his workouts last week, Allen jogged the same amount of time each day for 6 days. Use the following information to determine the number of mi
What number is 33% of 1,000
trust paragraph and concluding paragraph for "thank you m'am"?(so my little sister has English 8 and we she needs help on making a good trust paragraph using 3