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
igor_vitrenko [27]
4 years ago
13

C++ :Write a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the outpu

t is either heads or tails. Assume the input is a value greater than 0. If the input is 3, the output is:a.headsb.tailsc.headsFor reproducibility needed for auto-grading, seed the program with a value of 2. In a real program, you would seed with the current time, in which case every program run output would be different, which is what is desired but can't be auto-graded. Your program must define and call a function: string HeadsOrTails() that returns "heads" or "tails".
NOTE: A common student mistake is to call srand() before each call to rand(). But seeding should only be done once, at the start of the program, after which rand() can be called any number of times.
Computers and Technology
1 answer:
yaroslaw [1]4 years ago
3 0

Answer:

#include <iostream>

#include <cstdlib>

using namespace std;

int t;

char HeadsOrTails(){

char a='h';

char b='t';

if(t%2==0)

return a;

else

return b;

}

int main ()

{

 int n,  c, b;

   

 cout << "Enter the number of decisions you want" << endl;

 cin >> n;

 b=1;

 cout << "Decisions are:" << endl;

  srand(100);

 for (c = 1; c <= n; c++)

 {

   

   t = rand();

   if(HeadsOrTails()=='h'){

    cout<<b<<".heads"<<endl;

    b++;

   }

   else{

    cout<<b<<".tails"<<endl;

    b++;

   }

   

 }

 return 0;

}

Explanation:

random number generator is used to generate a number and then heads and tails is decided on even and odd number basis. if number is even then decision is head and if number is odd then decision in tails

You might be interested in
Rom a game design perspective, including some risks in your game can help make it both exciting and challenging, but also what e
wolverine [178]

Answer:

Depends on the player base

Explanation:

I would say rewarding to be honest because people like rewards and if they look cool people might play even at their bedtime but humorous might make players play the game more to see the jokes but I kind of doubt it, frustrating... they either rage or try to beat the quest or whatever it is to flex or something I don't know and confusing, like the frustrating one but people are into mystery so I think C would be better then B but I don't know about the other 2 so In my opinion I would say D

8 0
3 years ago
Using powerpoint 2016, ethan develops a short five-slide presentation for his marketing project. â â powerpoint files consist of
Lady bird [3.3K]
b. Ribbons  - Powerpoint 2016 has a tabbed ribbon system that groups relevant menus together according to category. The ribbon contains a number of tabs, each having a separate group of commands. The tabs can be used to do most of the common tasks in Powerpoint.
8 0
3 years ago
Is it possible for the front and rear references in a circular array implementation to be equal?
azamat

Answer:

Yes it is possible for the following cases:-

  1. When the queue is full.
  2. When the queue is empty.

Explanation:

When the queue is full the the front and the rear references in the circular array implementation are equal because after inserting an element in the queue we increase the rear pointer.So when inserting the last element the rear pointer will be increased and it will become equal to front pointer.

When the queue is empty the front and rear pointer are equal.We remove an element from queue by deleting the element at front pointer decreasing the front pointer when there is only one element and we are deleting that element front and rear pointer will become equal after deleting that element.

7 0
3 years ago
10x10=
ahrayia [7]

Answer:

100

Explanation:

10+10+10+10+10+10+10+10+10+10= 100

6 0
3 years ago
Read 2 more answers
A(n) ________ button is one that when you click one time it turns the feature on and when you click again, it turns off.
cupoosta [38]
It's a toggle button
5 0
3 years ago
Other questions:
  • Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley. Nice to meet you." becomes:
    9·1 answer
  • You are an inexperienced excel user and don���t know how to create your own formulas. you want to use one of the preconfigured f
    5·1 answer
  • In a doubly linked list, every nodecontains the address of the next node and the previousnode except for the ____ node.
    8·1 answer
  • Why is it a good idea to save work in the cloud
    10·2 answers
  • When using IPsec, how can you ensure that each computer uses its own private key pair?
    12·1 answer
  • What is the meaning of the title Two Kinds Of Stupid whose fault is it that Eduardo got in trouble
    8·1 answer
  • If you are involved in a collision that results in property damage, injury, or death, you must call
    13·1 answer
  • John travels a lot and he needs to access his documents and services on the go. Which of these technologies allows his to access
    5·1 answer
  • Which case would benefit from Explainable Artificial Intelligence (AI) principles?
    5·2 answers
  • Being technologically literate requires being able to ______. a. use advanced graphics manipulation tools (adobe photoshop) b. u
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!