What will be the value of k after the execution of the follo
What will be the value of k after the execution of the following MATLAB code? k=0; for i=1:5 end end a) 10 b) 14 c) 15 d) 25 e) 26
Solution
k=0;
for i=1:5
for j=1:5
k=k+1;
end
end
% The answer is 25.
% Explenation: Inner loop will increase the value by 1 for each iteration. So for
% each iteration of complete inner loop k value will be 5. The outer loop also
% iterate for 5 times so 5 X 5 times the nested loop will iterate a total of 25
% times. So k value will be increased 25 times to making its value 25
