CS1371_Spring_2008_Test1_Ver_C_solutions

CS1371_Spring_2008_Test1_Ver_C_solutions - CS1371 -...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CS1371 - Computing for Engineers Test 1 Version C February 6, 2008 TEST 1 – VERSION C Part 1 – Multiple Choice [30 Points] 1. Given: vec = [5 9 6 3 6 8] Which of the following will not return the vector v2 = [5 6 3 6 8] ? A. v2 = vec(vec < 9) B. v2 = vec([1 3:6]) C. v2 = vec; v2(vec == max(vec))=[] D. v2 = vec(vec ~= 9) E. v2 = vec; v2(vec > 9)=[] 2. What will be the final value of a when this script is executed? vec = [3 7 4 2]; [a, b] = max(vec); if a == b a = a + b; elseif a > b a = a - b; else a = b - a; end A. 11 B. 9 C. 3 D. 5 E. -3 3. Consider these three iterative loops: I. vec = [5 3 7] x = 0 for i = vec x = x + i end II. vec = [5 3 7] x = 0 for i = 1:length(vec) x = x + vec(i) end III. vec = [5 3 7] x = 0 while length(vec) >= 0 x = x + vec(1) vec(1) = [] end Which of the following is correct? A. I and II are equivalent B. I and III are equivalent C. II and III are equivalent D. I, II, and III are all equivalent E. None of the above are equivalent Page 1 of 9
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS1371 - Computing for Engineers Test 1 Version C February 6, 2008 4. Given: cell = {'fred', 1:4, 3.14} cell{2} = []; What is the final value of cell ? A. {'fred', [], 3.14} B. {'fred', 3.14} C. {'fred', {}, 3.14} D. {'fred', [1 3 4], 3.14} E. Error 5. Which of the following will give a vector of length five with random numbers between 1 and 4? A. 3*rand(1, 5) + 1 B. rand(1, 4, 5) C. 4*rand(5) D. 4*rand(1, 5) + 1 E. None of the above 6. Which of the following is not a valid operation (will produce an error) if str = 'abc' ? A. prod(str) B. max(str) C. mod(str, 2) D. length(str) E. All of the above are valid operations 7. The following code is executed: A = {[4 3 2 1] 'abc' [true false true false]} out1 = class(A{3}); out2 = class(A{2}); What are the values of out1 and out2 ? A. out1 = 'cell' out2 = 'char' B. out1 = 'cell' out2 = 'cell' C. out1 = 'logical' out2 = 'cell' D. out1 = 'double' out2 = 'char' E. out1 = 'logical' out2 = 'char' 2
Background image of page 2
CS1371 - Computing for Engineers Test 1 Version C February 6, 2008 8. Which of the following is a valid function header? A. function = fun(input) B. function ret1, ret2 = fun(input) C . function ret = fun(34) D. function fun E. [ret1, ret2] = fun(input1, input2) 9. Consider the following script (assume a value will be given for the variable clown ): redNose = 'rudolph'; switch clown __________________________________ clowncar = 'Sleigh from Santa'
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/08/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Institute of Technology.

Page1 / 9

CS1371_Spring_2008_Test1_Ver_C_solutions - CS1371 -...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online