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]
2 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]2 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
Which of the following is the correct style tag for having the web page's text be aligned to the right?
uysha [10]

Answer:

B. style=text-align: right

Explanation:

text-align is a CSS property having 5 types of values. Each of values define below.

left - Aligns content to left.

right - Aligns content to right.

center - Centers the content.

justify - Depends on the width of the content, it will align itself to both left and righ

inherit - It specifies the the value of text-align should be taken from parent element.

8 0
3 years ago
Read 2 more answers
What types of forecast worksheets are available in Excel? Check all that apply.
Oksana_A [137]

Answer:

C, D

Explanation:

ya welcome:)

5 0
2 years ago
Read 2 more answers
Name at least four factors that are looked at when a lender considers whether you are creditworthy.
emmasim [6.3K]
Sepa la verga cx I don't even know this
6 0
3 years ago
The soft-tissue lining of oysters and clams creates pearls. Is a pearl a mineral?
Kisachek [45]
<span>A pearl is not a mineral because it is created artificially. It is a gemstone, not a mineral because it is a composite of mineral Aragonite and a protein compound which is called conchiolin. Pearls are formed by organic and living organisms which is preserved to become a gemstone.</span>
3 0
3 years ago
Read 2 more answers
Eli needs to export files from his mailbox into a single file that is portable and can be backed up to removable media. Which fi
Ray Of Light [21]

Answer:

ZIP

Explanation:

The best file type for this scenario would be a ZIP file. This is a file that holds various different files compressed into a single file, with a file extension of .zip . This file type is used for two main reasons, the first being to combine various files into a single file that can be easily sent or stored. The second reason is to shrink the total file size of a large set of files, which is done by compressing the files themselves into a single entity. Therefore, this would be the best option for Eli in this situation.

5 0
2 years ago
Other questions:
  • A(n) _______________ supplies one of the most critical aspects of docking stations, but in a smaller, more portable format: supp
    15·1 answer
  • Which is true about POP3 and IMAP for incoming email?
    12·1 answer
  • The use of IDPS sensors and analysis systems can be quite complex. One very common approach is to use an open source software pr
    9·2 answers
  • 1. Some of the music in the 1960s was used to protest social and political issues. Is music still used as a form of protest? Why
    13·1 answer
  • When using a presentation software you can change the size of the text to...? Increase Font size, Decrease font size, increase t
    15·2 answers
  • What is segmentation and paging?
    12·1 answer
  • Truck drivers probably can't see your vehicle if ______________.
    11·2 answers
  • What is the basic purpose of the International Space Station that will be completed in 2010?
    11·1 answer
  • What is social media ​
    13·2 answers
  • If you are using a sprite for your MakeCode Arcade game, which code block
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!