This preview shows pages 1–3. Sign up to view the full content.
CSE 131
Final Exam, Fall 2005
(BLUE version)
Page 2 of 12
Section A: Array FETCH Operations
Question 1:
After the following code fragment is run, what is the value of y?
x = [1,2,3; 4,5,6; 7,8,9];
y = x([1,2], end1:end)
a) [2,3,5,6]
b) [1,2;3,4]
c) [2,3; 5,6]
d) [1,2,3; 4,5,6]
Question 2:
After the following code fragment is run, what is the value of y?
z = [1,2; 2,1];
y = [z(1,:); z(:,2)']
a) [1,2; 2,1]
b) [1,2,2,1]
c) [1,2,1,2; 2,1,2,1]
d) [2,1; 1,2]
Question 3:
After the following code fragment is run, what is the value of p?
x = [7,2,3; 0,4,8; 5,6,1];
p = x(1,2)*x(2,:) + x(end,:)
a) [0,8,16]
b) [0,8,17]
c) [5,14,25]
d) [5,14,17]
Question 4:
After the following code fragment is run, what is the value of z?
x = [10,100;50,100];
y = x';
z = [x(:,end)'; y(end,:)]'
a)
[100,100; 100,100]
b) [10,50; 10,50]
c) [100,100,100,100]
d) [100,100; 100,10]
Question 5:
After the following code fragment is run, what is the value of x?
y = 'Ashley Ohio is my home.';
x = y(1, 8:12)
a) Ashley
b) Ohio
c)
home
d)
none of the above
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentCSE 131
Final Exam, Fall 2005
(BLUE version)
Page 3 of 12
Section B: Creating Vectors
Question 6: Which of the following choices will generate a vector p whose elements are
the following?
3, 3, 9
a)
p = linspace(3, 3, 9)
b)
p = linspace(3, 3, 9)
c)
p = linspace(3, 9, 3)
d)
p = linspace(9, 3, 9)
Question 7: Which of the following choices will generate a vector p whose elements are
the following?
3, 3, 9
a)
p = 3:3:9
b)
p = 3:6:9
c)
p = 3:9:6
d)
p = 3:9:3
Section C: FIND Operations
Question 8:
After the following code fragment is run, what is the value of y?
x = [2, 0, 5, 8, 10];
y = find (x>7)
a)
[2, 0, 5, 8, 10]
b) [4,5]
c)
[8, 10]
d)
[1, 2, 3]
Question 9:
After the following code fragment is run, what is the value of z?
This is the end of the preview. Sign up
to
access the rest of the document.
 Spring '08
 Sticklen

Click to edit the document details