answer.
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]
2 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]2 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
Describe the output when the following code executes in 64-bit mode: .data dividend_hi QWORD 00000108h dividend_lo QWORD 3330002
iragen [17]

Answer:

RAX = 333000h (16 bits with preceding zeros removed)

RDX = 20h (also 16 bits with preceding zeros removed)

Explanation:

The "div" opcode in the assembly language source code is used to divide operands. It accepts a divisor ( the denominator) and divides the content of the AX register. The result is saved in the AX register while the remainder (if any) is saved in the DX register. If the DX register holds any data, the data is replaced with the divisor remnant.

The code above divides the content of the RAX register with the divisor variable and saves the result and remainder in the RAX and RDX respectively.

7 0
2 years ago
If Maya wants to access a view that would control multiple slides within a presentation, which view should she utilize? Master v
Basile [38]

Answer:

I think it’s slide shorter view

Explanation:

6 0
2 years ago
Ben uses a table that has few columns. He knows about a particular value in the first column and wants to find the corresponding
igor_vitrenko [27]
I'd suggest he uses LOOKUP Function.

You can use the LOOKUP function when you need to look in a single column or row and find a value from the same position in a corresponding column or row. We have a much improved VLOOKUP that can also be used to search one row or column or multiple rows and columns.



4 0
2 years ago
Read 2 more answers
Assume that k corresponds to register $s0, n corresponds to register $s2 and the base of the array v is in $s1. What is the MIPS
BlackZzzverrR [31]

Answer:

hello your question lacks the C segment so here is the C segment

while ( k<n )

{v[k] = v[k+1];

     k = k+1; }

Answer : while:

   bge $s0, $s2, end   # while (k < n)

   addi $t0, $s0, 1    # $t0 = k+1

   sll $t0, $t0, 2     # making k+1 indexable

   add $t0, $t0, $s1   # $t0 = &v[k+1]

   lw $t0, 0($t0)      # $t0 = v[k+1]

   sll $t1, $s0, 2     # making k indexable

   add $t1, $t1, $s1   # $t1 = &v[k]

   sw $t0, 0($t1)      # v[k] = v[k+1]

   addi $s0, $s0, 1

   j while

end:

Explanation:

The MIPS assembly code corresponding to the C segment is

while:

   bge $s0, $s2, end   # while (k < n)

   addi $t0, $s0, 1    # $t0 = k+1

   sll $t0, $t0, 2     # making k+1 indexable

   add $t0, $t0, $s1   # $t0 = &v[k+1]

   lw $t0, 0($t0)      # $t0 = v[k+1]

   sll $t1, $s0, 2     # making k indexable

   add $t1, $t1, $s1   # $t1 = &v[k]

   sw $t0, 0($t1)      # v[k] = v[k+1]

   addi $s0, $s0, 1

   j while

end:

4 0
2 years ago
You have installed a device at the physical layer. All of the systems you connect to this device will talk to each other at the
9966 [12]

Answer: Hub

Explanation:

Hub is a electronic and networking device that is placed in a network to maintain a common link with the multiple attached devices. Hub is situated at the physical layer of the Open systems interconnection(OSI) model.

  • Hub is used for creation of link between numerous local area network sections as it persist various ports which replicates data packet and distributes to other ports.
  • There are different types of hub for different purpose of connection such as USB hub, Ethernet hub etc.  

8 0
2 years ago
Other questions:
  • A(n) ____ is an electronic device, operating under the control of instructions stored in its own memory, that can accept data, p
    14·1 answer
  • A search box does all of the following EXCEPT ________.
    12·2 answers
  • Zander is beginning to take college courses to prepare for a career in computer science, which is the study of using logic to cr
    5·1 answer
  • Mrs. Johnson is here today to receive an intercostal nerve block to mitigate the debilitating pain of her malignancy. Her cancer
    13·1 answer
  • You are on vacation and want to see where all the restaurants and trendy shops are in relation to your hotel. You remember there
    15·1 answer
  • Write an if-else statement that displays 'Speed is normal' if the speed variable is within the range of 24 to 56. If the speed v
    5·1 answer
  • Consider the formula: G=D+(A+C^2)*E/(D+B)^3 Show the order that a processor would follow to calculate G. To do so, break down th
    10·1 answer
  • Which item follows html instructions to assemble web pages
    13·1 answer
  • What text results in variable white space (blank) texts results In even white space
    9·1 answer
  • Write a function that takes a string like 'one five two' and returns the corresponding integer (in this case, 152). A function j
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!