MIS 24053 Lecture Notes - Lecture 6: Plain English, Switch Statement, Truth Table
Document Summary
A conditional statement allows us to control whether a program segment is executed or not. Syntax action if(condition) if the condition is true then execute the action. action is either a single statement or a group of statements within braces. // program to read number & print its absolute value. #include using namespace std; int main(){ int value; cout << "enter integer: "; cin >> value; if(value < 0) cout << "the absolute value is " << value << endl; return 0; value = -value; Relational operators are used to compare two values to form a condition. [ (a=b) means put the value of b into. C++ contains a type named bool for conditions. A condition can have one of two values: true (corresponds to a non-zero value) false. Boolean operators can be used to form more complex (corresponds to zero value) conditional expressions.