Tutorial 8


Assignment operators are +=, -=, *=, /=, %=. Conditional operator ?: is the operator that is used in place of if-else. e.g. f = (a>b)?c:d, this means if a>b, then f =c else f=d. sizeof operator provides the size of variable in bytes. Comma operator is used to separate multiple expressions in single line. Scope resolution operator :: is used to distinguish between global and local variable that have same name in the program. Expression is an operand or a combination of operands and operators which, when evaluated, yields a single value. Expressions are constructs, denoting rules of computation for obtaining values of variables and generating new value by the application of operators. Expressions comprise of operators and operands, i.e. variables, constants and functions. Type conversion is sometimes required in the expressions in C++, because unsigned variables do not change to higher value data types automatically, so we need to specify temporary data type change of the variable in order to keep the accuracy of the output of the expression. Syntax is : (data type) expression e.g. (double)a. Order of Precedence provides the sequence to compute expression having different operators. First Multiplication, division, modulus, remainder, addition, subtraction. On the top of this order of precedence is Parentheses.