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

  Desirable to force users to creat an explicit choice

Why is it not desirable to force users to build an explicit choice of a query processing strategy? Are there cases where it is desirable for users to be aware of the costs of competing query-processing strategie.

  How to defend against attacker on the web

Even just talking on the phone can be a security risk, according to Harwood, there will be a slight increase in risk due to all the vulnerabilities

  How many bytes of memory is this

Suppose you discover that RAM addresses 000C0000 to 000C7FFF are reserved for a PC's video adapter. How many bytes of memory is this?

  How can we determine a maximal spanning tree in a network

The topological sorting functions as presented in the text are deficient in error checking. How can we determine a maximal spanning tree in a network?

  Write a program that takes a phrase and then counts

Write a program that takes a phrase and then counts the number of vowels (case does not matter) in the phrase.

  Explain the typical way that project managers organize

Describe the typical way that project managers organize the programmers' work storage areas. Why is this approach useful?

  The entire shortest path problem from scratch

How would you verify if this statement is true or false using an efficient algorithm that does not solve the entire shortest path problem from scratch?

  Identify at least three possible use cases and actors

Create a state transition diagram that describes typical customer states and how they change based on specific actions and events.

  Implement needham-schroeder symmetric key protocol both

implement needham-schroeder symmetric key protocol both original version and fixed version using python.the term

  How will you explain how arrays are used

If you were explaining an array ti a friend who is learning Java. how will you do so?

  Design and implement a recursive descent parser

Design and implement a recursive descent parser for the following simple arithmetic expression.

  Define the weight of an edge e in e

NASA wants to link n stations spread over the country. Define the weight w(e) of an edge e in E as the bandwidth of the corresponding channel.

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