Docsity

Test 2 Version C with Solution - Computing for Engineers - Fall 2007 | CS 1371, Exams of Computer Science

Toggle sidebar
bg1
CS1371 – Test 2 Version C Solutions October 24th, 2007
CS 1371 Computing for Engineers
Test 2 Version C Solutions – Fall Semester 2007
Problem 1 – Structure Arrays [50 Points]
1. varA = A. {‘Name’;’Status’;’Duty’}
2. varB = B. 1
3. varC = A. 0
4. varD = C. ’DavidSeanNathanHarold’
5. varE = B. ’GarbageDishesFloorCounter-top’
6. varF = C. [25 40 30]
7. varG = D. Error
Problem 2 – File I/O [50 Points]
1. varA = C. 9
2. varB = A. ‘Ian’
3. varC = A. 0
4. varD = B.10
5. varE = A. 0
6. varF = B. 1
Problem 3 – Recursion [50 Points]
A. function ret = recursive_Cap(vec)
if length(vec)==0
ret = 0;
else
temp = vec(1);
if ((temp>=65) && (temp<=90))
ret = 1 + recursive_Cap(vec(2:end));
else
ret = recursive_Cap(vec(2:end));
end
end
B. E. None of the above
A. ret = 0.1
B. ret = 200
C. - Needs to have a terminating condition
- Needs to move towards termination
- Need to have a call to a clone of the function
pf2

Partial preview of the text

Download Test 2 Version C with Solution - Computing for Engineers - Fall 2007 | CS 1371 and more Exams Computer Science in PDF only on Docsity!

CS1371 – Test 2 Version C Solutions October 24th, 2007

CS 1371 Computing for Engineers

Test 2 Version C Solutions – Fall Semester 2007

Problem 1 – Structure Arrays [50 Points]

  1. varA = A. {‘Name’;’Status’;’Duty’}
  2. varB = B. 1
  3. varC = A. 0
  4. varD = C. ’DavidSeanNathanHarold’
  5. varE = B. ’GarbageDishesFloorCounter-top’
  6. varF = C. [25 40 30]
  7. varG = D. Error

Problem 2 – File I/O [50 Points]

  1. varA = C. 9
  2. varB = A. ‘Ian’
  3. varC = A. 0
  4. varD = B.
  5. varE = A. 0
  6. varF = B. 1

Problem 3 – Recursion [50 Points]

A.

function ret = recursive_Cap(vec) if length(vec)== ret = 0; else temp = vec(1); if ((temp>=65) && (temp<=90)) ret = 1 + recursive_Cap(vec(2:end)); else ret = recursive_Cap(vec(2:end)); end end B. E. None of the above A. ret = 0. B. ret = 200 C.

  • Needs to have a terminating condition
  • Needs to move towards termination
  • Need to have a call to a clone of the function

CS1371 – Test 2 Version C Solutions October 24th, 2007

Problem 4 – Plotting [50 Points]

A.

1. A, B

2. C, D

3. E

4. A, D

5. A, D

6. A, B, C, D

7. E

B.

  1. False
  2. True
  3. False
  4. True
  5. False