{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

D- Written Questions- Solutions and RubricExam 1

# D- Written Questions- Solutions and RubricExam 1 -...

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

14:440:127, Fall 2008 Exam 1 Version D “No Computer” Question 1: Answer whether the following questions evaluate to True or False : Let x = 100 and y = 15 a) y+5 >= 98 FALSE b) rem(x,y) > 3 TRUE c) fix(x/y) == 6 TRUE d) ~y FALSE e) length(x) == 3 FALSE (it’s a 1x1 matrix) f) x<100 | y<100 TRUE g) x ~= y TRUE Subtract 1 point for each incorrect answer. No partial credit is given for this question. “No Computer” Question 2: Write an If Statement that does the following. A) Displays “Both Positive” if both x and y are positive B) Displays “Both Negative” if both x and y are negative C) Displays “Different Signs” if x is positive and y negative, or vice versa D) However, if either x or y is zero, the if statement should only display “ZERO” You may assume that x and y have already been defined. if (x==0 | y==0) disp( 'ZERO' ) elseif (x>0 & y>0) disp( 'Both Positive' ) elseif (x<0 & y<0) disp( 'Both Negative' ) else disp( 'Different Signs' ) end OR You could have done this problem with the sign() function: if (~sign(x) | ~sign(y)) disp( 'ZERO' ) elseif (sign(x)+sign(y)==2) disp(

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.

{[ snackBarMessage ]}

### Page1 / 3

D- Written Questions- Solutions and RubricExam 1 -...

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

View Full Document
Ask a homework question - tutors are online