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

is a triangle with the angles of 13 degrees,18 degrees and 127 degrees possible or impossible​
Answer ASAP! 20 points
Escoge el mandato que signifique 'Take the cake to her.' Llévenlelo. Llévenselo. Llévenlase.
Which of the following statement best describes the position of slaves in Roman society
Please help please help
HELP (please don't write a random answer) What is the main idea of this passage? The Venus flytrap is a carnivorous plant that catches and digests prey, usual
Which variable is discrete a time to finish a race b temperature at start of race c number of runner in race d length of race in kilometers
Which net represent the solid?
Suppose a city with the population 100,000 has been growing at the rate of 8% per year. If the rate continues, find the population of this city in 21 years
Solve -4/3x+1/6<7/9< or >A. -34/27B. -17/24C. -11/24D. -22/27EDIT THE ANSWER IS >-11/24 I TOOK THE TEST