if2 - Programming If Statements & Relational Operators,...

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

View Full Document Right Arrow Icon
If Statements & Relational Operators, Part 2 Programming
Background image of page 1

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

View Full DocumentRight Arrow Icon
The if-else Statement Syntax if ( condition ) Action_A else Action_B if the condition is true then execute Action_A else execute Action_B Example: if (value == 0) cout << "value is 0"; else cout << "value is not 0"; condition Action_A Action_B true false
Background image of page 2
Choice ( if and else ) if <it's sunny>{ <go to beach> } else{ <take umbrella> }
Background image of page 3

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

View Full DocumentRight Arrow Icon
Finding the Big One int value1; int value2; int larger; cout << "Enter two integers: "; cin >> value1 >> value2; if (value1 > value2) larger = value1; else larger = value2; cout << "Larger of inputs is: " << larger << endl ;
Background image of page 4
if-else-if Statements if <condition 1 exists>{ <do Q> } else if <condition 2 exists>{ <do R> } else if <condition 3 exists>{ <do S> } else{ <do T> } Q R T S
Background image of page 5

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

View Full DocumentRight Arrow Icon
if-else-if Statements if <1PM or 7PM>{
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/30/2010 for the course COMP COMP102 taught by Professor Lrr during the Fall '09 term at HKUST.

Page1 / 15

if2 - Programming If Statements &amp; Relational Operators,...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online