Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For program 3 you will be working with 2D arrays and using nested for loops. You

ID: 3655999 • Letter: F

Question




For program 3 you will be working with 2D arrays and using nested for loops. You will create a square array, of a user defined size, filled with random integer values between 1 and 20. You will then move through each location in the array and prompt the user for a value to add to that location. At the end you will display the changed array. Helpful Information: - Check out the help page for the randi function. Specifically look at example 3. - When you are testing your program, try it by entering sizes for the array between 2 and 4. Higher sizes, while valid input, will make much larger arrays that could simply be annoying to test with. - It will make it easier if you make use of an index vector. Make sure it is of the same length as the dimensions of the array entered by the user. Remember what an index vector should contain and how we have discussed created vectors that could be applicable to this case. - We need to move through each value (every column) in every row, letting the user know the location you are at and prompting them for a value to add at that location. - For outputting the contents of the array, you can let the default variable printout in MATLAB take care of this for you in this case. Submission Instructions: - Name your program prog3.m in the manner we have used previously. Be sure to include the script header in the file you submit. Script header: %CSCI 251, Section 4 %Student Name %Student ID 00000000 Sample Output: >>prog3 Enter the size for the square array: 3 array = Moving to location 1,1. What would you like to add to this location? 3 Moving to location 1,2. What would you like to add to this location? 1 Moving to location 1,3. What would you like to add to this location? 14 Moving to location 2,1. What would you like to add to this location? 1 Moving to location 2,2. What would you like to add to this location? 7 Moving to location 2,3. What would you like to add to this location? 9 Moving to location 3,1. What would you like to add to this location? 17 Moving to location 3,2. What would you like to add to this location? 18 Moving to location 3,3. What would you like to add to this location? 0 array =

Explanation / Answer

%CSCI 251, Section 4 %Student Name %Student ID 00000000 clear all;clc; ArrSize=input('Enter the size for the square array: '); while(ArrSize
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote