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

Which group isolated Russia for hundreds of years?
Choose each conversion factor that relates cups to fluid ounces. A. 8floz1c B. 8c1floz C. 1floz8c D. 1c8floz
6. If Misty practices for eight hours a day, six days a week, how many total hours does Misty practice each week? How many hours in a year?
How did the U.S. Constitution handle the issue of slavery? A. It outlawed slavery throughout the country. B. It allowed each state to decide its own rules about
Hay cinco personas en mi familia. Mis padres, mi hermano, mi hermana menor y yo. Mi madre tiene cuarenta años. Mi padre tiene cuarenta y dos años. Mi hermano ti
I WILL BRAINLIST YOU​
Please help ASAP! Thank you so much!DUE SOON!
x/2+ 1 = 9 options: x = 16 x = 20 x = 4 x = 5
Assume that markup is based on selling price. Find the dollar markup and percent of markup on selling price. (Round your "Dollar markup" answer to the nearest c
What is 2 x 9 x 9 x 9 x 2 x 9 In index notation