What will be the output of the following code? [code]all(sin(pi), 1)[/code]

What will be the output of the following code?
Code:
all(sin(pi), 1)
A. 0
B. 1
C. Error
D. NaN
 
Answer: b
Explanation: sin(pi) is not 0 since pi is just a floating point variable in MATLAB. The output of sin(sym(pi)) would’ve been 0. Thus the output of the above code is 1 since the function all() returns 1 iff all the elements of the input vector is non-zero.
Output: 1
 

Tìm kiếm

Back
Top