Professional Documents
Culture Documents
and Assignment
Statements
Expression
Expression is the means of specifying
computations in programming language.
Arithmetic expression
Arithmetic expression is the programming
languages that inherited from mathematics
There are three types of operand:
Unary : contain single operand
Binary : contain two operand
Ternary : contain three operand
Example of Operator
Precedence
Example of Operator
Associativity
Parentheses
Parentheses is used to override the precedence
and associativity rules by placing parentheses in
expressions.
Narrow Conversion
Narrow conversion is convert a value to a type
that cannot store
In others word is convert from big to small
For example: convert from double to int in C++
Widening conversion
A widening conversion is convert a value of the
original type that can include at least
approximations of all values for the original type.
In others word is convert from small to big
For example: converting a int to a double in C++
Mixed-mode
Mixed-mode expression is which mean the
expression is different type of operands
If both operands have different types of data
types it is needed for the conversion of both
operands to same data types
Type of conversion
There are two type of conversion:
Casts refer to explicit conversion
Coercion refer to inexplicit conversion
Example
Relational Expression
The relational expression has two operands and one
relational operator
The value of relational expression is Boolean
Example of relational operators :
==,!=,<=,<,>
Example of relational expression in C++:
int input;
(input <=1000)
Boolean expressions
Boolean expressions consists Boolean variable, Boolean
constants, relational expression and Boolean operators
The operators include AND(&&), OR(||) and NOT(!)
Example of Boolean Expression:
(i>0)&& (j<10), (i>0)||(j<100)
Assignment statement
The assignment statement is using equal(=) for
assign the operands in the expressions.
The use of these operator must be different
from the equal sign to avoid the confusion
Example:
Compound assignment
The compound assignment operator is a
shorthand to specifying a common needed
form of assignment.
The method is assigning the first operand
in expression on the right side
Assignment as an Expression
Assignment as an Expression which produce the
result, has the same value assigned to the
target.
Multiple assignment
Multiple assignment is provide the multiple- target