{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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 Document Right Arrow Icon
undamentals I: If Statements & Relational Operators /Slide 2 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
undamentals I: If Statements & Relational Operators /Slide 3 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 Document Right Arrow Icon
undamentals I: If Statements & Relational Operators /Slide 4 Choice ( if ) Put multiple action statements within braces if (it's raining){ <take umbrella> <wear raincoat> }
Background image of page 4
undamentals I: If Statements & Relational Operators /Slide 5 Absolute Value // program to read number & print its absolute value #include <iostream.h> int main(){ int value; cout << "Enter integer: "; cin >> value; if (value < 0) value = -value; cout << "The absolute value is " << value << endl; return 0; }
Background image of page 5

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

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

{[ snackBarMessage ]}