Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help me solve program 0, 1 and 2 Thank you in advance Programming Assignment # 8 Points: 2 | CLO $2 Problem 0 Recreate the

Help me solve program 0, 1 and 2

Thank you in advance

image text in transcribed
Programming Assignment # 8 Points: 2 | CLO $2 Problem 0 Recreate the four examples uses of pointers we covered in class under section 7.5 that cover the following four cases: 1. non-constant pointer to non-constant data, 2. constant pointer to non-constant data, 3. non-constant pointer to constant data, and 4. constant pointer to constant data. Problem 1 (1 point) For each of the following, write a single statement that performs the indicated task. Assume that long integer variables valuel and value2 have been defined and that valuel has been initialized to 200000. a) Define the variable 1Ptr to be a pointer to an object of type long. b) Assign the address of variable valuel to pointer variable 1Ptr. c) Print the value of the object pointed to by 1Ptr. d) Assign the value of the object pointed to by 1Ptr to variable value2. e) Print the value of value2. f) Print the address of valuel. g) Print the address stored in 1Ptr. Is the value printed the same as the address of valuel? Problem 2 (1 point) Simulation: The Tortoise and the Hare In this problem, you will recreate one of the truly great moments in history, namely the classic race of the tortoise and the hare. You will use random number generation to develop a simulation of this memorable event and use pointers to store / track the position of the two race contestants. Our contenders begin the race at "square 1" of 70 squares. Each square represents a possible position along the race course. The finish line is at square 70. The first contender to reach or pass square 70 is rewarded with a pail of fresh carrots and lettuce. The course weaves its way up the side of a slippery mountain, so occasionally the contenders lose ground. There is a clock that ticks once per second. With each tick of the clock, your program should adjust the position of the animals according to the rules shown in the table below. Implement the "race course" as an integer array containing the numbers from 1 to 70. . Implement the positions of the tortoise and the hare as pointers, each pointing to the current location of the tortoise and hare. Use pointer arithmetic to change pointer locations. Think of an interesting way of showing the progress of the race on screen. CCCS 111 - Introduction to Programming University of Jeddah Animal Move type Percentage of the time Actual move Tortoise Fast plod 50% 3 squares forward Slip 20% 6 squares backward Slow plod 30% 1 square forward Hare Sleep 20% No move at all Big hop 20% 9 squares forward Big slip 10% 12 squares backward Small hop 30% 1 square forward Small slip 20% 2 squares backward

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions