What is the output of the following code? [code]function [die,absdif] = BDO(y,x) die = y-x; if nargout > 1 disp('Boo !') absdif

Ngoc Hue

New member
What is the output of the following code?
Code:
function [die,absdif] = BDO(y,x)
die = y-x;
if nargout > 1
    disp('Boo !')
    absdif = abs(die);
end
end
[p,q]=BDO(Inf,Inf)
A.
Boo!
p=NaN
q=NaN
B.
Boo!
p=0
q=0
C. Error
D. p=NaN
 
Answer: a
Explanation: Since the number of outputs sought are greater than 1, the if condition gets satisfied and ‘Boo !’ is printed. Inf-Inf will be NaN and hence both p and q will be equal to NaN.
 

Tìm kiếm

Back
Top