Question: This incorrect program should sum together all of the numbers in both inputs, array 1 and array 2 , and returns that sum as the

This incorrect program should sum together all of the numbers in both inputs, array1 and array 2, and returns that sum as the output totalSum. You can assume array1 and array2 have same length. Which one of the following statements is a reasonable correction? (Note: the correction may not fully fix the function)
function [totalSum]= programToFix(array1, array2)
totalSum =1; s??1?
n = arrayl;
for i=1:1:n8?2?
totalsum = array1(i)+ array2(i)+ totalSum; %?3?
end
In the line with the comment ?2?: The code should read totalSum(i)= array1(i)+ array2(i);
In the line with the comment ?2?: The code should read i=1:2: n
In the line with the comment ?2?: The code should read i=n:1:1
In the line with the comment ?1?: tota 1Sum should be initialized as 0
This incorrect program should sum together all of

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!