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

  Preparing and delivering technical communications

Critical Thinking Preparing and Delivering Technical Communications for Influential End Users

  For the arithmetic expressions below draw a binary tree

question for the arithmetic expressions below draw a binary tree that represents the expression and then use tree

  Write down code to complete the conversion

You've just started a new semester and you've become friends with one of your classmates, Tomislav. Tomislav tells you he has just moved to United States from Europe and he's having a difficult time adjusting to the English units of measurement. In..

  A sorting function to sort according to year

A sorting function to sort according to Year. Notice that the sort function has manage all five arrays while sorting. Display the results.

  Draw a simple connected directed graph with eight vertices

Draw a simple connected directed graph with 8 vertices and 16 edges such that the in-degree and out-degree of each vertex is 2.

  Create paraphrased versions of the given passages

Using what you learned about paraphrasing this week, create paraphrased versions of the following passages. The original passages define the terms ethics.

  Which is an example of a systems development life cycle

Which of the following is an example of a systems development life cycle? Why should you always create a project charter at the start of a project?

  What is output when the following code fragment is executed

What is the output when the following code fragment is executed?

  Describe the disaster recovery plan in detail

What is the difference between a disaster recovery plan and a business continuity plan? The response must be typed.

  Why menu-driven interfaces continue to be popular

Evaluate the user dialog strategies used by a menu-driven interface. Determine why menu-driven interfaces continue to be popular in the modern computing age.

  Write programs to generate a random text string

Write programs to generate a random 1000-bit text string, then find all occurrences of the last k bits elsewhere in the string, for lc= 5,10,15.

  What is the public key pu and what is the cipertext c

What is the public key PU? What is the private key PR? What is the cipertext C? How does the decryption to covert the ciphertext back to the plaintext M?

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