Question: Write a Matlab program that starts with a total of zero and uses a WHILE loop to keep adding a random integer between -1

Write a Matlab program that starts with a total of zero and

uses a WHILE loop to keep adding a random integer between -1

Write a Matlab program that starts with a total of zero and uses a WHILE loop to keep adding a random integer between -1 and +2 (i.e., either -1, 0, +1 or +2) to the total, until the total is greater than or equal to 100,000. The program should display the total as it runs and when finished tell the user how long it took to reach that total. Hint: one approach is for the program to stay in the WHILE loop while a variable called total hasn't been reached yet. Write a Matlab program that creates uses a 1 x 100 array of numbers and fills it with integers which count up from 1 to 50 and then down from 49 to 1 again (i.c., 1 2 3 4 ... 47 48 49 50 49 48 47 4 3 2 1). It should display the array on the screen.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!