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

Answer this problem CORRECTLY for 15 pts.
Traditional economies are also known as _____.
A number x is greater than or equal to – 7.
Explain the University of Minnesota's experiment with White Castle and why this is related to hamburger meat's negative reputation. I really need help with the
1. Jack swung the bat. He missed the ball. (compound sentence) * A. Jack swung the bat. He missed the ball. O B. Jack swung the bat he missed the ball. C. Jack
Use the periodic table to identify the number of core electrons and the number of valence electrons in each case below. Argon (Ar): [NE] 3s^23p^6
A 14.3-cm3 sample of tin has a mass of 0.104 kg.
What were the 3 Gs? three famous gold explorers Native Americans in Georgia first forts in Georgia reasons for Spanish exploration
Convert 1/10 to a decimal
Convert 132 cm to km