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

The self consciousness of the speaker is nowhere more evident than in lines 37-44 . What do you think he is self conscious and worried about in these lines? Is
what's the answer to this question in the blue box
Which of the following processes are exothermic and which are endothermic? a) frost forms on a car window in winter; b) water condenses on a glass of ice water
What is the degree of f?
Please explain and answer without Euler’s number
what's the answer to this question in the blue box
During the medieval period, which group played an important role in staging plays in various parts of towns? A. landholders B. shop owners C. peasants D. tr
Jodis car used 12 gallons of gas travel 456 miles. It cost Jodis $44.88 to buy 12 gallons of gas. What was the cost per gallon of gas
Can someone please help me with this page Thank You!!
Most of China’s population is located in the eastern half of the country, which has __________ climate Humid continental Humid subtropical Semiarid steppe Cool