# Logical Expressions – 1 MCQ’s

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “Logical Expressions – 1″.

1. The functioning of all() and any() is same.
a) True
b) False

2. What does the function all() do?
a) Returns 1 if all elements within it are 0
b) Returns 0 if all elements within it are 0
c) Returns 0 if all elements within it are non-zero
d) Returns 1 if all elements within it are non-zero

3. If a logical expression is true, it will always return a logical 1 and if it’s false, it’ll always return a 0.
a) True
b) False

4. Choose the correct hierarchy of operations.
a) |,&,+,-
b) +,-,&,|
c) :,+,-,&
d) |,:,&,.^

5. What will be the output of the following code?

`all([1 0])`

a) 1
b) 0
c) Error
d) Nan

6. What is the output of the following code?

`2++++++++9`

a) 11
b) 74
c) 25
d) Error

7. What will be the output of the following code?

`all([Nan])`

a) 1
b) 0
c) Error
d) Nan

8. What is the output of the following code?

`sin(Inf) & sin(nan)`

a) Error
b) 1
c) 0
d) Nan

9. What will be the output of the following code?

`~xor(3476,1234)`

a) 1
b) 0
c) Error
d) NaN

10. What will be the output of the following code?

`any(sin(0), NaN)`

a) 1
b) Error
c) 0
d) No such function

11. What will be the output of the following code?

`~or(~xor(1,1),~or(0,1))`

a) 1
b) 0
c) NaN
d) Error

12. What will be the output of the following code?

`any(xor(1,1), ~or(xor(1,0),1), sin(pi), NaN)`

a) 0
b) 1
c) Error due to too many arguments
d) Error due to NaN

13. What will be the output of the following code?

`all(sin(pi), 1)`

a) 0
b) 1
c) Error
d) NaN

14. What will be the output of the following code?

`all([or(1,1), ~xor(xor(1,0),1), cos(pi)])`

a) 0
b) 1
c) Error
d) No such function all

15. The correct hierarchy of operations is ________
a) <.<=,|,&
b) >,>=,&,|
c) <,>=,|,&
d) <,|,>,& 5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%