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

Post on 04-Jan-2016

216 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

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 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 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

top related