# if2 - Programming If Statements Relational Operators Part 2...

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

If Statements & Relational Operators, Part 2 Programming

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

View Full Document
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
Choice ( if and else ) if <it's sunny>{ <go to beach> } else{ <take umbrella> }

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

View Full Document
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 ;
Finding the Big One const double PI = 3.1415926; int radius; double area; cout << "Enter the radius of the circle: "; cin >> radius; if (radius > 0){ area = radius * radius * PI; cout << "The area of the circle is: " << area; } else cout << "The radius has to be positive " << endl ;

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

View Full Document
Even or Odd int value1; bool even; cout << "Enter a integer : "; cin >> value; if (value%2 == 0) even = true; else even = false; // even = f &value%2);
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 18

if2 - Programming If Statements Relational Operators Part 2...

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

View Full Document
Ask a homework question - tutors are online