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

plzzz help meee giving 50 pointsssssssss
(TEST) Select all of the ratios that are equivalent to 6:16. 3:8 2:8 30/80 12/18
[tex]( \frac{8}{11}) {}^{7 - 2 \times 3 - 1} [/tex]find the answer​
Which of the following sets of angles sum to 180°? picture included, please help.
Triangle ABC is shown on the coordinate plane below. Which of these represents the rotation of triangle ABC by 90º counterclockwise about the origin? The first
195% is equivalent to what fraction in reduced terms?
Solve for X for the angle
The ratio of two positive numbers is 3:4. The sumof their squares is 400. What is the sum ofthe num-bers?​
How much money would you say by purchasing vanilla cupcakes a dozen pack instead of buying 12 individual cupcakes
Based on your observations from Investigation 2, which of the following observations is correct?