Simulate a random walk using a coin flip

Assignment Help Computer Engineering
Reference no: EM132196984

This write this in C

Set up a simple int array that holds 11 elements. Simulate a "random" walk using a coin flip. The initial position is the middle of the array and if the coin flip is heads (0) move 1 step to the right, tails (1) move one cell to the left.

Each time they move into a cell the cell is incremented. After flipping the coin a given number of times (entered by the user) print out the total number of times the cell was occupied.

Print out "*" for each visit so that we can see the random walk graphically. Continue to do this until the user chooses to stop.

Example output:

Enter the number of times you would like to flip the coin:
12
*
**
****
****
*
Would you like to run this program again (y,n)?
n

Reference no: EM132196984

Questions Cloud

Define exception and throw when the fraction is instantiated : Write a class Fraction, define a exception and throw when the fraction is instantiated with zero in the denominator.
Swap the largest and last elements and display the result : Write a C++ program. Working with single-dimensional arrays using pointers. Key in the number n.
Display information about all elements of array of strings : Create a template structure "sports team" with the following fields: name, city; City, the number of players, the creation date (structure day is the meat-year)
Create a new tracking system : A landscape service has hired you to create a new tracking system. They have 2 types of appointments: morning and afternoon.
Simulate a random walk using a coin flip : Simulate a "random" walk using a coin flip. The initial position is the middle of the array and if the coin flip is heads (0) move 1 step to the right.
Explain advantages and disadvantages of globalization : Globalization brings with it both advantages and disadvantages, economic and otherwise. List some of each, according to your own view of globalization.
Create a dunbar object set the force of the object : Write the class that will carry out the following steps. This code would be part of a program, but you only have to write out the steps requested here.
Make the three data members private : Write a class to contain the following information about towns: the name (a sequence of characters); the population (an integer);
Draw a graph of typical indifference curves : Draw a graph of typical indifference curves, budget constraints, the optimal choice of a typical subscriber under the current fixed-rate policy.

Reviews

Write a Review

Computer Engineering Questions & Answers

  What are ethical issue involved with downloading source code

What are the ethical issues involved with downloading the source code and replacing your name and information on the page and using it on your home page?

  Speculate on the technological limitations regarding data

Using the organization you selected,B explain the key way(s) in which your organization / agency uses business intelligence in order to gain a competitive.

  What could be done to minimize their impact on the system

Identify and discuss the key Threat Agents. What could be done to minimize their impact on the system

  Evaluate the total with insurance

Enter the insurance rate as a mixed cell reference in the formula, making the row number absolute.

  Write src instructions to load a value into a register

Write SRC instructions to load a value into a register using each of the addressing modes of Table. Use multiple SRC instructions for mode only when necessary.

  Create an interface that acts as a simple two number

Create an interface that acts as a simple two number calculator. Your program should continue doing calculations until it is closed or exited.

  Open-addressing hashing method using quadratic probing

Write down the next four (4) locations we will attempt (suppose they also have collisions) if we are using Quadratic Probing?

  Explore the idea of first-in and last-out

Imagine that you're visiting a local all-you-can-eat breakfast bar; among the many items on the bar is a pan of biscuits.

  Compare two sets of characters

Your program will include a function called searcher that uses pointers to both the source string and the character set, and which returns a pointer to a char.

  Explain how the kernel treats zombies and orphans

Explain how the kernel treats zombies and orphans. Write a program that repeatedly prints the Shell> prompt to accept a UNIX command as argument.

  Define what are the steps necessary to fix the problem

Part of implementing Ken 7 Windows' new enterprise resource planning (ERP) software is setting up a new recovery procedure for each type of computer.

  Determine the duties of the system administrator

Determine the duties of the system administrator. Explain the differences between the system administrator and the network administrator.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd