0% found this document useful (0 votes)
941 views4 pages

(Help The Programmer) : Present Iterations (Wrong)

This document contains 20 multiple choice questions about functions, loops, and conditionals in MATLAB. The questions cover topics such as the purpose of functions, scope of variables, break and continue statements in nested loops, and using if/elseif/else statements.

Uploaded by

Jemuel Flores
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
941 views4 pages

(Help The Programmer) : Present Iterations (Wrong)

This document contains 20 multiple choice questions about functions, loops, and conditionals in MATLAB. The questions cover topics such as the purpose of functions, scope of variables, break and continue statements in nested loops, and using if/elseif/else statements.

Uploaded by

Jemuel Flores
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

• Question 1 Present Iterations (wrong)

0 out of 2 points
In nested loops, the continue statement, if present within a nested if structure, will exit the ____________

• Question 2 (help the programmer)


2 out of 2 points
What is one main purpose of a function?

• Question 3 (yes, bad form)


2 out of 2 points
Can you use the same name for a local variable as a global variable?

• Question 4 (True)
2 out of 2 points
A function can be called several times by placing a function call in the body of a for loop.

• Question 5 (Range of statements)


2 out of 2 points
In Function, What is a variable’s scope?

• Question 6 (temporary variable)


2 out of 2 points
In Function, What is a local variable?

• Question 7 (5040)
4 out of 4 points

If the genearted random value for variable num = 7, what will be the ouput of this code? _____

• Question 8 – parentheses()
2 out of 2 points
The condition of a while loop can be written inside _____.

• Question 9 (x>0&&x<5)
2 out of 2 points
What is the correct Matlab expression for checking to see if a number stored in a variable x is between 0
and 5.

• Question 10 (last started ongoing)


2 out of 2 points
In nested loops, the break statement exits the ____ loop.

• Question 11 (0) (wrong)


0 out of 5 points
How many lines will be the output of executing this code?

function hello( )

fprintf("Hello \n");

fprintf("Glad to meet you");

end

• Question 12 (false)
2 out of 2 points
Local variables can be referenced outside of the function they were defined in.

• Question 13 (display 55)


5 out of 5 points
Consider the following code.

nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

for w = 1: 10

accum = 0;

accum = accum + w;

end

disp(accum);

What happens if you put the initialization of accum inside the for loop as the first instruction in the loop?

• Question 14 (row)
2 out of 2 points
In a nested loop, outer loop represents what?

• Question 15 (II only)


5 out of 5 points
Which among I , II, and III below gives the same result as the
following nested if?

% nested if-else statement


x = -10;
if x < 0
disp("The negative number " + x + " is not valid here.");
else
if x > 0
disp(x + " is a positive number");
else
disp(x + " is 0");
end
end

I.

if x < 0
disp("The negative
number " + x + " is
not valid here.");
else (x > 0)
disp(x + " is a
positive number");
else
disp(x + " is 0");
end

II.

if x < 0
disp("The negative number " + x + " is not valid here.");
elseif (x > 0)
disp(x + " is a positive number");
else
disp(x + " is 0");
end

III.

if x < 0
disp("The negative number " + x + " is not valid here.");
end
if x > 0
disp(x + " is a positive number");
else
disp(x + " is 0");
end

• Question 16 (a number)
2 out of 2 points
The number of iterations run for any loop by MATLAB is always _____________

• Question 17 (current iteration)


2 out of 2 points
In nested loops, the continue statement exits the ____

• Question 18 (entire loop)


1 out of 1 points
In nested loops, the break statement, if present within a nested if the structure, will exit the _______

• Question 19 (column)
2 out of 2 points
Copy of

In a nested loop, inner loop represents what?

• Question 20 (true)
2 out of 2 points
While running a loop in MATLAB, it does not require indentation.

You might also like