Question: Write a program that (a) generates a vector with 20 random integer elements with integers between -10 and 10, (b) replaces all the negative integers

Write a program that (a) generates a vector with 20 random integer elements with integers between -10 and 10, (b) replaces all the negative integers with random integers between -10 and 10, (c) repeats (b) until all the elements are positive. The program should also count how many times (b) is repeated before all the elements are positive. When done, the program displays the vector and a statement that states how many iterations were needed for generating the vector.

Step by Step Solution

3.17 Rating (172 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Script file clear clc vector randi 2012010 iter 0 N1 while N 0 N1 for k120 if v... View full answer

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

Document Format (1 attachment)

Word file Icon

652-B-F-F-M (699).docx

120 KBs Word File

Students Have Also Explored These Related Finance Questions!