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

1530 Given the following list: x [29, 67, 71, 33, 46, 79, 91, 44, 12, 39, 69, 11

ID: 3720388 • Letter: 1

Question

1530 Given the following list: x [29, 67, 71, 33, 46, 79, 91, 44, 12, 39, 69, 11, 84, 56, 84, 23, 96, 97, 45, 53, 97, 91, 64, 73, 50, 18, 19, 37, 10, 30, 18, 30, 87, 79, 54, 34, 59, 45, 69, 61, 74, 38, 63, 59, 84, 47, 72, 80, 44, 17, 34, 42, 98, 89, 15, 49, 98, 24, 77, 99, 45, 85, 29, 32, 65, 73, 56, 24, 19, 25, 75, 84, 53, 39, 43, 38, 76, 15, 19, 21, 22, 43, 53, 21, 33, 59, 61, 32, 74, 38, 31, 19, 24, 51, 42, 79, 25, 88, 94, 34, 14, 70, 18, 58, 99, 52, 86, 76, 57, 95, 87, 70, 39, 41, 82, 62, 91, 43, 85, 65, 72, 16, 75, 87, 58, 17, 66, 73, 95, 61, 98, 10, 32, 17, 58, 31, 59, 44, 98, 17, 40, 85, 77, 69, 27, 59, 32, 18, 93, 17, 74, 65, 23, 49, 52, 72, 56, 19, 45, 52, 71, 43, 52, 93, 51, 10, 25, 10,45, 23, 17, 75, 98, 85, 44, 26, 44, 66, 35, 38, 73, 99, 93, 87, 49, 46, 59, 95, 56, 95, 48, 27, 39, 90, 21, 80, 91, 36, 81, 36]; NOTES IMAGES DISCUSS UNITS STATS HELP Part Description Answer Chk History Use a 'for' loop to find the sum of every other number, beginning with the first number 8.33 pts, 50% A. # tries: 0 Show Details 10% try penalty 10 try limit Hints: 0,0 Use a 'for' loop to find the sum of every other number in the previous list, beginning with the second number 8.33 pts, 50% # tries: 0 show Details 10% try penalty 10 try limit Hints: 0,0 8.33 pts, 50% What is the sum of all the values of x that are less than 49? ?. # tries: 0 Show Details 10% try penalty 10 try limit

Explanation / Answer

% Matlab program to find the sum of the list of numbers under various
% conditions
% subset of given list , replace the entire list
x = [29,67,71,33,46,79,91,44,12,39,69,11,84,56,84,23,96,97,45,53,97,91,64,73,50,18,19,37,10,30,18,30,87,79,54,34,59,45,69,61,74];

second_sum=0;
second_list=0;
ns = 1;
%A. loop to find the sum of every other number beginning with the first number
for i=1:2:length(x)
second_sum = second_sum + x(i);
second_list(ns) = x(i); % create a list of every second number of x
ns = ns+1;
end
% B. loop to find the sum of every second number in the previous
% list(second_list) starting with the second number
next_sec_sum =0;
for i=2:2:length(second_list)
next_sec_sum = next_sec_sum + second_list(i);
end
% C. loop to find the sum of all values less than 49
sum_less_49 =0;
for i=1:length(x)
if(x(i) < 49)
sum_less_49 = sum_less_49 + x(i);
end
end
% D. loop to find the sum of (x(i)+i)^2 for all i=9 to 155
sq_x = 0;
for i=9:155
if(i < length(x))
sq_x = sq_x + ((x(i)+i)^2);
end
end
% print the result
fprintf(' Sum of every other element in x starting from first number : %d',second_sum);
fprintf(' Sum of every other element in previous list starting from second number : %d',next_sec_sum);
fprintf(' Sum of element in x less than 49 : %d',sum_less_49);
fprintf(' Sum of (x(i)+i)^2 for i=9 to 155 : %d',sq_x);

  
% end of program

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