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 makes a hydrocarbon saturated?
True or false: An absolute value function is an example of a piecewise function.
plsss answer my questions in the picture​
Problem example: For the given sequence: -2,2,6,10,14,18 Write a recursive formula to find the nth term: a = an-1+4 Write a explicit formula to find the nth te
a pacific seahorse eats about 56 shrimp per week how much does it eat per day
Help help help math help please
Mary………..the bus on Sundays A. don’t catch B. have not caught C. doesn’t catch D. didn’t catch
Directions: Transform the following equations into standard form. 1. x2 + 2x = -1 2. 4 + x2 = 7x 3. x2 - x = 1 4. x2 + 9x = 10 5. 4x + 3 = x2 6. x2 + 5x +5 7. 2
can you plz help me....
In a fruit punch drink, the 3 ingredients are apple juice, orange juice and cranberry juice. If 1/4 of the drink iS apple juice and 2/5 is orange juice then wr