Top Banner
1 REVIEW 1 EXAM 3
26

1 REVIEW 1 EXAM 3. Question 1 Which statement(s) is/are valid to create a string? a. x = “EGR 115” □ Valid □ Invalid b. x = ‘EGR 115’ □ Valid □ Invali.

Jan 04, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 2: 1 REVIEW 1 EXAM 3. Question 1 Which statement(s) is/are valid to create a string? a. x = “EGR 115” □ Valid □ Invalid b. x = ‘EGR 115’ □ Valid □ Invali.

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

Page 3: 1 REVIEW 1 EXAM 3. Question 1 Which statement(s) is/are valid to create a string? a. x = “EGR 115” □ Valid □ Invalid b. x = ‘EGR 115’ □ Valid □ Invali.

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

Page 5: 1 REVIEW 1 EXAM 3. Question 1 Which statement(s) is/are valid to create a string? a. x = “EGR 115” □ Valid □ Invalid b. x = ‘EGR 115’ □ Valid □ Invali.

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

Page 6: 1 REVIEW 1 EXAM 3. Question 1 Which statement(s) is/are valid to create a string? a. x = “EGR 115” □ Valid □ Invalid b. x = ‘EGR 115’ □ Valid □ Invali.

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

Page 7: 1 REVIEW 1 EXAM 3. Question 1 Which statement(s) is/are valid to create a string? a. x = “EGR 115” □ Valid □ Invalid b. x = ‘EGR 115’ □ Valid □ Invali.

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

Page 23: 1 REVIEW 1 EXAM 3. Question 1 Which statement(s) is/are valid to create a string? a. x = “EGR 115” □ Valid □ Invalid b. x = ‘EGR 115’ □ Valid □ Invali.

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