June 12, 2021

More about Loops – 1 MCQ’s

Read Time:1 Minute, 56 Second

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

1. What is the output of the following code?

i=0;for j=0:2  
j=j-1
end

a) Infinite loop
b) -1
c) Output is suppressed
d) +1

2. What is the output of the following code?advertisement

a=0;for j=0:2  
j=j+1 end

a) Syntactical Error
b) 3
c) 2
d) Keyword Error

3. What is the output of the following code?

i=0;for i=0:2  
i=1; end

a) Output is suppressed
b) Output shows 1 3 times
c) Output shows 1 2 times
d) Error

4. What is the output of the following code?

for j= 4:2   
j=j+1 
end

a) an empty vector, j
b) 3
c) 2
d) error

5. What is the output of the following code?

for i!=1:10 
p=p+1;

a) Syntactical Error
b) Inf
c) NaN
d) Logical Error

6. What is the final value of j from the following code?

for j=(0:3)  
j=j+1;
end

a) Syntactical error
b) Declaration error
c) 3
d) 4

7. In nested loops, the continue statement exits the ____
a) current iteration
b) loop
c) inner
d) outer

8. In nested loops, the break statement, if present within a nested if the structure, will exit the _______
a) Ongoing if structure
b) Entire loop
c) Ongoing loop
d) Entire if structure

9. In nested loops, the break statement exits the ____ loop.
a) external
b) last started ongoing
c) not available in MATLAB
d) for

10. In nested loops, the continue statement, if present within an if structure, will exit the ____________
a) If structure
b) current iteration
c) entire loop
d) Error

11. What is the output of the following code?

for j= 4:2:2   
j=j+4 
end

a) Error
b) j=6
c) Error an empty vector, j
d) Syntactical error

12. The effective working of the continue keyword in the final iteration is same as the effective working of the break keyword.
a) True
b) False

13. In nested loops, the continue statement, if present within a nested if structure, will exit the ____________
a) If structure
b) nested if structure
c) entire loop
d) present iteration

14. The number of iterations run for any loop by MATLAB is always _____________
a) a positive integer
b) a negative integer
c) a number
d) a decimal number

15. While running a loop in MATLAB, it does not require indentation.
a) True
b) False

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous post Logical Expressions – 2 MCQ’s
Next post More about Loops – 2 MCQ’s