1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aniked [119]
2 years ago
6

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 k

now if they are correct or incorrect
Computers and Technology
1 answer:
Evgen [1.6K]2 years ago
6 0

#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;

}

You might be interested in
Necesito 7 innovaciones tecnológicas de la informática para 2021
Sonja [21]

‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍  ‍

3 0
3 years ago
Which describes a design theme in PowerPoint? a set of elements that unify the slides and complement the topic a printed handout
chubhunter [2.5K]

a set of elements that unify the slides and complement the topic

5 0
4 years ago
Read 2 more answers
Binary Numbers and Conversion 1. Complete the following decimal-to-binary number conversions. a) 17 (10) b) 34 (10) c) 58 (10) d
GaryK [48]

Answer:

a) 10001

b)100010

c)111010

d)1111100

e)1110111

f)10110010

g)100101001

h)110011101

Explanation:

7 0
3 years ago
Which of the following statements is true?
Alex787 [66]
Seasons are caused by the earths changing distance from the sun
6 0
3 years ago
Here's something to stop you from getting repetitive when writing essays. Write a program that reads multiple lines of plain tex
Marianna [84]

Answer:

The output is attached below

Explanation:

d = {}

while True:

line = input("Enter line: ")

if len(line)==0:

break

token = line.split(' ')

for var in token:

try:

if len(var)==0:

continue

count = d[var]

d[var] = count + 1

except KeyError:

d[var] = 1

pass

for word in sorted(d):

print(word , d[word])

------------------

7 0
4 years ago
Other questions:
  • How can the connection to salesforce be restricted only to the employee portal server? Universal containers (UC) uses a legacy E
    13·1 answer
  • What are the best apps to learn coding
    15·2 answers
  • The inner planets are called terrestrial because they
    11·2 answers
  • Use the line of code below to choose the correct answer
    10·2 answers
  • Consider a system that contains 32K bytes. Assume we are using byte addressing, that is assume that each byte will need to have
    10·1 answer
  • What is one way a senior employee can mentor a new employee? Give orders about what to do and what not to do Gossip about which
    10·1 answer
  • modified true or false analyze each statement then write technical the statement is true the statement is false underline the wo
    6·1 answer
  • In which conditions, a trial balance does not tally?
    14·1 answer
  • Write a 10 sentence paragraph about george washington and abraham lincoln and no plagiarism
    8·2 answers
  • How do films use camera shots?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!