1 review 1 exam 3. question 1 which statement(s) is/are valid to create a string? a. x = “egr...

26
1 REVIEW 1 EXAM 3

Upload: chrystal-freeman

Post on 04-Jan-2016

218 views

Category:

Documents


0 download

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