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 are three real-life examples of genetic engineering that are occurring right now?
why do mangroove tree survive in the water?
Why did president franklin d. roosevelt establish social security?
carlisle purchased one-fourth of a pound of candy at the mall. what decimal did he see on the scale
A thermogram identifies the warm and cool parts of an object by using a. radio waves. c. ultraviolet waves. b. microwaves. d. infrared waves.
Find the product. (-4·3·2)2 -48 48 -576 576
are humans are very good at detecting deception
Evaluate 4|-2| - |-3|
What are three real-life examples of genetic engineering that are occurring right now?
Why is the value of function : f(x)= 10x + 2 when x=5?