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

This is for people who did flvs United States History 02.01 Industrialization Changes America i need a complete and correct assignment that will get me over a 8
Work out the difference between 88.1 and 2.81.
1. explain the role sports medicine plays in athletics today
explain why an egg white omelet is not a great idea.
Why are indexing rules important when filing names alphabetically? (Obj. 1)
I need help with my world history assignment plz anyone
Hello I’m in algebra and I need help on questions I’ll give brainlist ASAP ANSWER BOTH PLS !
What is the scale factor?
One fragment of a given integer N can be selected and its digits reversed (replaced with a right to left version of themselves). What is the maximum number that
The area of the base of this trapezoidal prism is 15 square units and the width is 8. What is the volume?