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
1. Insert a Header that has the following in excel​
Fofino [41]

Answer:

Go to Insert and click on Text and underneth that click header and footor.

Explanation:

You can do a Header and Fotter in Excel. ALl you have to do if go in the document you are working in and you click on Instert tab and then click on Header and Fotter. It gives you an option to make a header for your excel wookbook.

7 0
3 years ago
How can I make my Wi-Fi signal fast? I am going through my exam but my Wi-Fi is not supporting plz help.
9966 [12]

Answer: Maybe try to move router.

Explanation:

8 0
3 years ago
11111 Power 2 sovle ​
erastovalidia [21]
123,454,321. you just multiply 11111 by itself
4 0
3 years ago
CompX Inc. is an online retailer of electronic products, including laptops and tablets. The company is known for its unique appr
Dafna1 [17]

Answer:

Differentiation

Explanation:

Differentiation is a business strategy used by organizations for gaining a competitive edge over competitors in the market.

During this approach, the organizations/business introduces a special strategy which goal is to differentiate their product or service in a positive way, from other products that are alike.

In this scenario the organization(CompX Inc) is offering a superior customer support.

6 0
3 years ago
Imagine you accidently mistype the URL for your bank and you are redirected to a fake website that collects your information. Wh
fgiga [73]

Answer:

Financial identity theft

Explanation:

Financial identity theft is a fraudulent act that involves accessing someone's personal information without their consent or approval for fraudulent financial gain.

A typical financial identity theft is someone stealing your credit card information such as pin, cvv, etc. to make other financial transactions without your knowledge.

7 0
3 years ago
Other questions:
  • What is the purpose of the “little down arrow” next to many different functions in word
    6·1 answer
  • A customer has contacted you to help him alleviate the large amount of time and effort that goes into adding and removing users
    12·1 answer
  • Count the number of words in the string. A word is one or more non-blank characters separated by one or more blanks. My suggesti
    13·1 answer
  • You're setting up some VMs to test an application you're considering making available to employees of the small company you work
    11·1 answer
  • What do level meters show?
    8·1 answer
  • Why are computers useful for modeling situations?
    13·2 answers
  • How does recorded audio stay on an audio tape
    12·1 answer
  • For example, consider a file with protection mode 644 (octal) contained in a directory with protection mode 730. How might the f
    9·1 answer
  • Tips for staying safe using social media. Using in your own words.
    6·1 answer
  • List at least 5 disadvantages caused by computer viruses?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!