{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS100 Midterm 2009

# CS100 Midterm 2009 - Lahore University Of Management...

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

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

View Full Document
1. (3 points) What is the value of b at the end of this program? b = 0; for a=1:5 b = [b a^2]; end Answer box The value of b at the end of this program is ________________________________________ 2. (3 points) What is the value of b(5) at the end of this program? b = ones(1,5); for a=2:5 while b(a) <= b(a-1) b(a) = 2*b(a); end b(a) = b(a) + 3; end Answer box The value of b(5) at the end of this program is ________________________________________ 3. (3 points) List the output displayed by the following code: a = 10; b = -5; while b < a b = b + 1; a = a - 2; disp(num2str(a + b)); end ; Answer Box
4. (3 points) The code below draws four circles. figure; axis equal; axis([0 100 0 100]); x = [10 90 90 10]; y = [10 10 90 90]; for p=1:4 rectangle('position', [[x(p), y(p)]-4 8 8], 'curvature', [1 1]); end Cross out one of the two words in each of the four boxes below: The first circle is drawn near the upper / lower left / right corner. The second circle is drawn near the upper / lower left / right corner.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.
• Spring '11
• SohaibKhan,ArifZaman,MurtazaTaj
• Harshad number, Lahore University of Management Sciences, School of Science and Engineering, elseif rand, Arif Zaman

{[ snackBarMessage ]}

### Page1 / 11

CS100 Midterm 2009 - Lahore University Of Management...

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

View Full Document
Ask a homework question - tutors are online