counter counter index; end Answer: counter 3. What is the value of n at the end
ID: 3703806 • Letter: C
Question
counter counter index; end Answer: counter 3. What is the value of n at the end of the loops? n-2; while n 10 appear at the end of the loops? counter = 2; while (2 counter 10) disp (2 counter is still 10) counter counter+1; end Answer: ( times 5. What is the value of ii at the end of the loops? for ii 2:3:11 ifii == 5 break; end end Answer: ii-() 6. What is the value of ii at the end of the loops? for i 2:3:11 continue; end end Answer: ii () 7. What is the value of ires at the end of each of the loops? ires -20 while ires>-50Explanation / Answer
Answer:
3) here the while loop runs untill n<49.initially the value of n is 2 and is incremented by 2 in the while loop.so the values of n will be 2,4,6,8,.........46,48.here 48 is still less than 49 so one more time the while loop will run.but when the value of n is incremented by 2 to 50.it comes out of while loop (since 50 > 49).therefore the final value for n will be 50.
4) Here in the question it is asked about the statement " 2*counter is still >10 ".But in the code snippet the display statement is " 2*counter is still <10 ".Therefore the above statement will not appear in any condition.In case if the statement was " 2*counter is still <10 ",it would have been displayed 2 times.
5) In this case the format used for For loop is " for index=start_value : increment_value : end_value " so for ii=2:3:11 means intially ii=2 and it is incremented by 3 each time.In the foor loop if ii becomes equal to 5 it breaks i.e it comes out of loop.So in the 2nd iteration when 3 is added to 2.It becomes 5 and since it satifies the if condition in the loop.it will come out of the loop.Therefore the final value for ii will be 5.
6) It is same as question 5 except here if ii equals to 5 it continues.It means it will keep incrementing the ii value becmoes 11.here on 4th iteration the ii value will be 11 and it will come out of loop since the end_value was 11.Therefore in this case the final value for ii will be 11.
!! Hope you like my answer !! Please leave a comment for more explanation or any doubts !!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.