# More about Loops – 2 MCQ’s

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “More about Loops – 2″.

1. Multiple graphs can be plotted, in the same window, if we use the ___ command in a loop.
a) hold on
b) held on
c) hold off
d) not possible

2. The number of iterations in the following loop is

```p=3;for i=(3:4)
p=p+2;
end```

a) 0
b) 1
c) 3
d) 4

3. The for loop performs at least ___ iteration/s.
a) 1
b) not necessarily an iteration
c) 2
d) Error

4. What is the output of the following code?

```a=0;for i=[1:1]
q=a-55;
end```

a) Syntactical Error
b) Declaration error
c) Output is suppressed
d) q=-55

5. What is the output of the following code?

```q=0;for i=(1:1)
q=q+5;
end```

a) Output is suppressed
b) Syntactical error
c) q=5
d) Declaration error

6. What is the nature of the error in the following statement?

`for i=1:`

a) Incomplete
b) Unexpected operator
c) Invalid keyword
d) No error

7. What is the output of the following code?

```i=0; while[i<5]
i=i+1;
end```

a) Syntactical Error
b) Declaration Error
c) Output is suppressed
d) i=5

8. What is the nature of the error in the following statement?

`for i=:1`

a) Incomplete syntax
b) Unexpected MATLAB operator
c) No such keyword
d) No error

9. What is the output of the following code?

```while{i<5}
i=i+1234;
end```

a) i=1234
b) Output is suppressed
c) Error in converting the cell to logical form
d) Error in i

10. The condition of a while loop cannot be given in ________
a) ()
b) []
c) {}
d) <>

11. What is the output of the following code?

```i=0;while(i<5)
i=i-1;
end```

a) Error
b) i=-Inf
c) i=NaN
d) Infinite loop