1 review 1 exam 3. question 1 which statement(s) is/are valid to create a string? a. x = “egr...
TRANSCRIPT
Question 1 Which statement(s) is/are valid to create a string?
a. x = “EGR 115” □ Valid □ Invalid
b. x = ‘EGR 115’ □ Valid □ Invali
c. x = sprintf(‘ %s %d’,class_name,class_num) □ Valid □ Invalid
d. x = str2num(‘115’) □ Valid □ Invalid
e. x=num2str(‘115’) □ Valid □ Invalid
f. X=double(‘EGR’) □ Valid □ Invalid
2
Question 2 This rand statement will give a random number between
6 and 10, the question is which set (from the ones specified below) is correct to represent the possible outcome?
Rand_num= round((rand*4)+6)
a. {6,7,8,9}
b. {7,8,9,10}
c. {7,8,9}
d. {6,7,8,9,10}
3
Question 3 A TYPICAL keyboard is considered to be:
a. Input device
b. Output device
c. Input/output device
d. None of the above
4
www.wikipedia.com
Question 4 When using the ‘r+’ access mode, the initial position of
the pointer will be:
a. At the beginning of the file
b. At the end of the file
c. At halfway into the file
d. It will stay where it is (no change from last time the file was open)
5
Question 5 Assuming that we are reading a text file that includes
only one line and we saved it to a variable named str, look at the screenshot below can you tell which function was used to read such file:
a. fgetl()
b. fgets()
c. fget()
d. None of the above
6
Question 6 Assuming that we are reading a text file that includes
only one line and we saved it to a variable named str, look at the screenshot below can you tell which function was used to read such file:
a. fgetl()
b. fgets()
c. fget()
d. None of the above
7
Question 7 The part that is circled is called:
function W = M (A,B)
a. function
b. Return variables
c. Function name
d. Parameters
8
Question 8 Consider the code written below, then answer the
following questions:
a. If a file exists with the same name should it be deleted?
b. If the files doesn’t exist, should it be graded?
9
Question 9 Consider the code written below, then answer the
following questions:
a. If a file exists with the same name should it be deleted?
b. If the files doesn’t exist, should it be graded?
10
Question 10 Consider the code written below, then answer the
following questions:
a. If a file exists with the same name should it be deleted?
b. If the files doesn’t exist, should it be graded?
11
Question 11
Which of the following built-in function, will CREATE a plot.
a. polyval()
b. polyfit()
c. Xlabel()
d. polar()
12
Question 12
Consider the following MATLAB code, and decide where is the error:
a. The error is in the FIRST line.
b. The error is in the SECOND line.
c. The error is in the THIRD line.
d. The error is in the FOURTH line.
13
Question 13
14
The part that is circled is called:
function W = M (A,B)
a. function
b. Return variables
c. Function name
d. Parameters
Question 14
15
The part that is circled is called:
W = MyFun (A,B)
a. Function call
b. Return values
c. Arguments
d. Parameters
Question 15
polyfit() will return the coefficient of the polynomial that best fits the data given.
a. This statement is TRUE
b. This statement is FALSE
16
Question 16
Consider the following MATLAB code, and decide which type of data you are collecting
R = xlsread('myFile.xls');
a. numerical
b. strings
c. Cell array
d. Choice a & c are correct.
17
Question 17
What value will be in the variable len after executing this MATLAB code:
a. 10
b. 11
c. 12
d. 13
18
Question 18
strcat() is a built-in function that can be used to delete _____________ spaces from a string.
a. Leading spaces
b. Intermediate spaces
c. Trailing spaces
d. All spaces
19
Question 19
After running this MATLAB code, what value will be saved in the variable str_edit
a. Hello Wo
b. lo W
c. lo Wo
d. loWo
20
Question 20
21
After running this MATLAB code, what value will be saved in the variable str
a. Hello World
b. HelloWorld
c. [ ]
d. Will return an error message
Question 21
What will appear in the command window after executing this code:
z=5;
fprintf('The answer is z')
a. The answer is 5
b. The answer is z
c. The answer is 5.00
d. Will return an error.
22
Question 22
Where is the error:
for k=1:3
prompt=('Player #',num2str(k),':');
Play(k)=input(prompt);
end
a. The error is in the FIRST line.
b. The error is in the SECOND line.
c. The error is in the THIRD line.
d. The error is in the FOURTH line.
23
Question 23
24
What is the value stored in the variable chk chk=strcmp(‘yes’,’Yes’)
a. 0
b. 1
c. [0 1 1]
d. [1 1 1]
Question 24
What is the value stored in the variable chk chk=strcmpi(‘yes’,’Yes’)
a. 0
b. 1
c. [0 1 1]
d. [1 1 1]
25
Question 25
What is the value stored in the variable chk
chk= (‘Mark’ == ‘mark’)
a. 0
b. 1
c. [1 1 1 1]
d. [0 1 1 1]
26