Lecture 3 Notes

Clause in the construct the else clause does not have

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: onstruct if boolean expression if boolean expression statements to execute if expression is true statements to execute if expression is true else end statements to execute if expression is false end 34 1/30/14 1/30/14 30 1/31/14 Do these two fragments do the same thing? % given x, y if x>y disp(‘alpha’) else disp(‘beta’) end The if-elseif construct if boolean expression1 statements to execute if expression1 is true % given x, y if x>y disp(‘alpha’) end if y<=x disp(‘beta’) end elseif boolean expression2 statements to execute if expression1 is false but expression2 is true : else statements to execute if all previous conditions are false end A: yes B: no 1/30/14 31 Things to know about the if construct 1/30/14 32 Things to know about the if construct n༆ n༆  n༆  n༆  n༆  At most one branch of statements is executed There can be any number of elseif clauses else clause There can be at most one The else clause must be the last clause in the const...
View Full Document

This document was uploaded on 03/11/2014 for the course CSCI 004 at Brown.

Ask a homework question - tutors are online