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 is the best way to memorize arabic vocabulary?
What is 3 1/6 + 8 2/9 - 1 1/2 plz show work
what is one of the biggest criticisms of the USA PATRIOT act
which state is due north of pennsylvania PLEASE HELP ME
What is the best way to memorize arabic vocabulary?
changes in the earth's surface have largely been the result of: a. winds b. glaciers <---- my answer c. internal forces d. external forces is glaciers the co
What impact did World War I have on the Ottoman Empire? A. The Ottoman Empire ceded much of its territory, and European nations took control. B. There was an in
Municipal bodies are created by
Abe and Ben each have a certain number of dollars. If Abe gives Ben $5 then Abe and Ben will have the same number of dollars. If Ben gives Abe $5 then Abe will
how do I get the answer to 0.6 divided 25.2