if - Programming If Statements Relational Operators...

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

View Full Document Right Arrow Icon
If Statements & Relational Operators 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
Conditional Statements A conditional statement allows us to control whether a program segment is executed or not. Two constructs if statement if if - else if - else - if switch statement
Background image of page 2
The Basic if Statement Syntax if ( condition ) action if the condition is true then execute the action . action is either a single statement or a group of statements within braces. condition action true false
Background image of page 3

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

View Full DocumentRight Arrow Icon
Choice ( if ) Put multiple action statements within braces if (it's raining){ <take umbrella> <wear raincoat> }
Background image of page 4
Absolute Value #include <iostream> using namespace std; int main(){ int value; cout << "Enter integer: ";
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/07/2011 for the course COMP 102 taught by Professor Daniel during the Spring '08 term at HKUST.

Page1 / 16

if - Programming If Statements Relational Operators...

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

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