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

Page 127 "And there on the small screen was the burnt house, and the crowd and something with a sheet over it and out of the sky, fluttering, came the helicopte
Why did France donate a massive statue to the United states
1) A bacterial cell is viewed under a microscope. It doubles every 20 seconds. Which method of reproduction is most likely being viewed? A) Binary fission B) Co
What was the difference beliefs of the federalists and the democratic republican
The length of a rectangle is 3 centimeters less than twice its width. If the perimeter of the rectangle is 18 centimeters. find its dimensions Equation: ? Lengt
When you add 34 by 822 and then once once you answer that, give a real world example of the equation.
rx+9/5 = h (solve for x) please show work and only put correct answers, thanks!
a girl is literally desperate. help a girl out please lol with the right answers..
make a SHORT poem on bamboo​
What is the equation for the line that is perpendicular to line f, through E