09 More Conditionals
Oct 10, 2006
Announcements
• A2  still due Thursday at noon
• Grades on webpage
– clicker issues still not up, but
should be by end of week
• A1 going up as they are marked
• Midterm alternate time – email
went out.
• Midterm Oct 19th
if … else
if (true_or_false)
{
/* do something if the integer value was true */
}
else
{
/* do something else if it was false */
}
else.c
Logical Operations
• Logical operations are
mathematicallike operations
that return a value of 0 or 1.
• They were designed to be used
with if statements.
Logical Operators
(equality)
• x==y
–
0 if x is not equal to y
–
1 if x is equal to y
–
don’t confuse this with x=y (set x to be equal to y)
• x!=y
–
0 if x is not not equal to y – I.e. equal to y
–
1 if x is not equal to y
Logical Operators
Comparison
• x>y
–
0 if x is not greater than y
–
1 if x is greater than y
• x<y
–
0 if x is not less than y
–
1 if x is less than y
• Also
–
x>=y (greater than or equal to)
–
x<=y (less than or equal to)
• logical.c
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 '06
 Kramer

Click to edit the document details