What are the contents of a and b after the following events? [code]Line 1: function p=avg(x) Line 2: n = length(x); Line 3: n=n+3 Command

What are the contents of a and b after the following events?
Code:
Line 1: function p=avg(x)
Line 2: n = length(x);
Line 3: n=n+3
Command Window: 
>> x=[1 2 3 5]
>> dbstop in avg if length(x)>4
>> a=avg(x);
>> x=[1 2 3 4 5];
>> b=avg(x);
A. Error in the function
B. a=4,b=5
C. Enters debugging mode at b but a=4
D. Outputs are suppressed
 
Answer: b
Explanation: The dbstop command would work if the function is called after we have given the dbstop command. It won’t affect the working of the function if the function is called any more number of times i.e the condition provided in the dbstop command won’t result in entering the debugging mode if the working of the function does not satify it.
 

Tìm kiếm

Back
Top