What is the output of the following code? [code]syms x c; if(x~=c) fprintf(‘Error’); end[/code]

What is the output of the following code?
Code:
syms x c; 
if(x~=c)
fprintf(‘Error’); 
end
A. Error
B. Error due to x
C. Error due to c
D. Error due to x and c
 
Answer: a
Explanation: Since we declared x and c with the syms command, they have been assigned to the variable ans. Hence, matlab would have printed ‘Error’. The output won’t be suppressed.
 

Tìm kiếm

Back
Top