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
Elden [556K]
3 years ago
11

Write a program that lets the user guess the coin's head or tail. The program randomly generates an integer 0 or 1, which repres

ents the head or the tail. The program prompts the user to enter a guess and reports whether the guess is correct or incorrect. include step by step commentary.
Computers and Technology
1 answer:
svlad2 [7]3 years ago
7 0

Answer:

#include <iostream>

#include <stdlib.h>

#include <time.h>

using namespace std;

int main()

{

   srand (time(NULL));  //initialize random seed

   int guess;

    int number = rand() % 2;  //generate random number 0 or 1

    cout<<"Enter the guess (0 or 1): ";

    cin>>guess;     //store in guess

    if(number == guess){     //check if number equal to guess

       cout<<"Guess is correct."<<endl;   //if true print correct message.

    }else{

        cout<<"Guess is incorrect."<<endl;  //otherwise print correct message.

    }

    return 0;

}

Explanation:

first include the three library iostream for input/output, stdlib,h for using the rand() function and time for using the time() function.

create the main function and initialize the random number generation seed, then generate the random number using the function rand() from 0 to 1.

after that, take input from user and then with the help of conditional statement if else check if random number is equal to guess number or not and print the appropriate message.

You might be interested in
Regarding the Internet of Things (IoT), a business involved in utilities, critical infrastructure, or environmental services can
love history [14]

Answer:

The answer is False

Explanation:

IOT or Internet of things refers to the multiple devices in the world today, which are connected to the internet, they gather and share specific information. Any physical object can become an IOT device once it can be connected to the internet to control its data.

Since, the business is involved in utilities, critical infrastructure, or environmental services, it will not benefit from traffic-monitoring applications.

7 0
3 years ago
Which of the following is an external hard drive
fredd [130]

Answer:

Question 1 = D

Explanation:

7 0
3 years ago
100 POINTS NEED ASAP PLEASE HELP
givi [52]

It is actually podcast! i took the quiz as well :)

3 0
3 years ago
Read 2 more answers
Name the major types of computer systems from slowest to fastest. ​
Vadim26 [7]

Answer:

Cache is the fastest and most expensive, RAM is slower and less expensive, and virtual memory is the slowest and least expensive type.

Explanation:

3 0
3 years ago
Columns can be added to a page in the page layout tab in the blank grouping
ZanzabumX [31]

Answer:

Page Setup Grouping.

Explanation:

In Microsoft Word, Columns break up the page into, at max, 13 columns, and at minumum, 2. The way you go about doing this is

  1. Go to the Layout Tab
  2. Go to the Page setup Grouping
  3. Click on the Columns Action
  4. In the Dialog Box, choose either from one of the presents, or custom make your own column settings.
  5. Click Okay
  6. Done!

3 0
4 years ago
Read 2 more answers
Other questions:
  • Combination lock uses three numbers beween 1 and 36 with repetition , how mant combinations are possiable
    6·1 answer
  • Write a program that asks the user to input four numbers (one at a time). After the four numbers have been supplied, it should t
    6·1 answer
  • Which data type stores images and audio visual clips?
    9·2 answers
  • When is the bond between the actin and myosin head is broken? when an ATP molecule binds to the myosin head when an ATP molecule
    6·1 answer
  • John would like to move from the city into the suburbs and has been saving up a large down payment for a home. Which is the most
    7·1 answer
  • What are three softwares for cloud computing
    8·1 answer
  • What does aperture control? A)amount of light the image sensor captures when taking a photo. B)how sensitive the camera is to in
    10·2 answers
  • What is data? why is it important to collect data ? explain the points.​
    10·1 answer
  • Which option is used to ensure the integrity and authenticity of a Word document but requires additional services to be availabl
    5·2 answers
  • Which type of information should never be given out on social media?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!