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 are the dimensions of the vertical cross section shown on this right rectangular prism show. Below
Question 21 of 25NextWho was allowed to vote in colonial society?A) everyoneOB) Native AmericansOC) white male property ownersOD) married women​
please help and explain step by step​
oliver had saved $72.35 in his bank account, but decided to splurge on a very expensive present for his mom on mothers day. after he brought her present, his ba
cuanto es 2-{[-3x(-7+3x5)-2-3x9]-3+2x6} ayuda porfavor <3 <3
How is the orbital configuration of neutral atoms related to the atoms chemical properties
Given the speeds of each runner below, determine who runs the fastest. Noah runs 8 feet per second. Jessica runs 358 feet in 34 seconds. Adam runs 1 mile in 44
What generalization can you make about the seven cities of gold?
Mention Five blessing of god and appreciate them​
2/3y + v = x (solve for x) please show work, thanks!