14-440-127 Recitation 2 Presentation

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

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

View Full Document Right Arrow Icon
Ke Xu IF Statements - Review >> if (condition) statements end >> x = input ( ’A positive integer?’ ) disp( ’Yes. Positive integer. \n’) end
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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;
Background image of page 4
Image of page 5
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 Right Arrow Icon
Ask a homework question - tutors are online