(Using Expressions, Statements, Operators and Conditional Statement) Prepared By: Sallar Khan Contents O Expression O Assignment Operators O Arithmetic Operator O Increment and Decrement Operators O Relational Operators O Logical Operators O If-Else Conditional Statements O Nested If Else Statement O Switch Case Expression O An expression is a sequence of operators and their operands, that specifies a computation. O Expression evaluation may produce a result (e.g., evaluation of 2+2 produces the result 4) Assignment Operators O The assignment operator assigns a value to a variable. O X=5 This statement assigns the integer value 5 to the variable x. The assignment operation always takes place from right to left, and never the other way around. Arithmetic Operators The five arithmetical operations supported by C++ are: operator description + addition - subtraction * multiplication / division % modulo Increment Or Decrement Operators O Some expression can be shortened even more: the increase operator (++) and the decrease operator (--) increase or reduce by one the value stored in a variable. O E.g: i++ or i-- Relational & Comparison Operators O Two expressions can be compared using relational and equality operators. For example, to know if two values are equal or if one is greater than the other. Operator Description == Equal to != Not equal to < Less than > Greater than <= Less than or equal to >= Greater than or equal to Logical Operators O ( !, &&, || ) O ! Represents NOT operation. O && Represents AND operation. O || Represents OR operation. If-else Conditional Statement O The if...else executes body of if when the test expression is true and executes the body of else if test expression is false. Nested-If else Statement O Nested if...else are used if there are more than one test expression. Switch Case O Consider a situation in which, only one block of code needs to be executed among many blocks. This type of situation can be handled using nested if...else statement but, the better way of handling this type of problem is using switch...case statement. ..Switch Case (Syntax) Thank You!
© Copyright 2026 Paperzz