14-440-127 Recitation 2 Presentation

14-440-127 Recitation 2 Presentation - IF Statements -...

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

Ke Xu IF Statements - Review >> if (condition) statements end >> x = input ( ’A positive integer?’ ) disp( ’Yes. Positive integer. \n’) end

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

View Full Document
Ke Xu IF-ELSE Statements >> if (condition) statement1 else statement2 end >> x = input ( ’A positive integer?’ ) disp( ’Yes. Positive integer.’ ) else disp( ’No. Not a positive integer.’ ) end
Ke Xu IF-ELSEIF-…-ELSE Statements >> if (condition) statement1 elseif statement2 else statement3 end >> x = input ( ’A positive integer?’ ) disp( ’Yes. Positive integer.’ ) elseif ( x<0 ) disp( ’No. That is negative.’ ) elseif ( x-fix(x) ) disp( ’No. Positive but non-integer.’ ) else disp( ’Zero is an integer, but neither + or -.’ ) end

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

View Full Document
Comments xpos=2; ypos=3; account = account – 100; disp(’You are in Jail’) disp(’You are fined \$100) end xpos=2; ypos=3; % account = account – 100;
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/29/2012 for the course 440 127 taught by Professor Blase during the Fall '09 term at Rutgers.

Page1 / 9

14-440-127 Recitation 2 Presentation - IF Statements -...

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

View Full Document
Ask a homework question - tutors are online