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

find the area of the triangle if the length is 22 and the height is 15
Su voluntad es dura como el acero. 3. El brillo de sus dos perlas azules. 4. Te dije mil veces que laves los platos
A reaction that is spontaneous at low temperature can become non spontaneous at high temperature if δh is\
Which of the following helped Japan’s economy recover following World War II?
If x represents the molar solubility of b a 3 ( p o 4 ) 2 , what is the correct equation for the k s p ?
What is the area of the figure shown delow?
a railroad crossing sign has a diameter of 30 inches. what is the area of the sign?
Something that causes stress is known as a(n) _______.
Good evening! Can someone please answer this, ill give you brainliest and your earning 50 points. Would be very appreciated.
Which statements correctly describe the role the christian church and monasteries had in preserving learning and spreading christianity? choose all answers that