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 specifically does STR measure? A) STR length B) the number of repeating units C) distance traveled on electrophoresis gel D) the difference between the
What protects living things from too much ultraviolets radiation?
Messenger rna is formed in the process of _____.
Why are the temperatures lowest in December?
What american led the organization in writing by what declaration?
what are the discontinuities of the function y= 1500/x
What is 57% of 11? Use an equation to solve the problem.
what is the vertex of the equation x2-3x=10
Which sentence segment contains a punctuation error? "yes i visited crested butte, colorado, last winter," replied mrs. souza.
What is the difference between velocity and speed??