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

which best defines a sonnet?
You are making fruit baskets using 54 apples 36 oranges and 73 bananas. Explain why you cannot make identical fruit basket without left over fruit.
the quotient of four and twenty
18 is what percent of 12?
why is there more heat in an iceberg then a pot of boiling water
If we did not have enzymes, would we all be malnourished? like, enzymes are the things that break down what we eat. they also absorbed the nutrients. so, i thin
In a matrix, can there be decimals and fractions?
Michelle buys 13 bags of gravel for her fish aquarium. If each bag weighs 12 pounds,how many pounds of gravel did she buy?
how many miles is covered by S forest
Fran start push up with 5 and increase by 3each day How many will be on 28 the day Total push up done that point