I need help understanding these two questions. I have managed to do all of my assignments in Matlab without using/understanding these type of problems but they are on my midterm review. I have the answers but can't seem to grasp how to arrive at them. I understand how to use while and for loops in the codes that I have written, but can't figure out the answers to these questions. Help with either one would be greatly appreciated!
The output of the following code is? Answer is sum=18
fprintf('sum= %d \n', sum)
What is the final value for y in the code below? Answer is -49
Also, how many times will the 'for' loop run? Answer is 7
Here is the code:
for x= 1:2:13
Any help will be greatly appreciated. My textbook is pretty useless and I cannot figure these out.