EXPRESSION AND THEIR TYPES
An expression is a combination of operators, constants and variables arranged as per the rules of the language.It may also include functions calls which return values.An expression may consist of one or more operands , and zero or more operators to produce a value. expressions may be of the following seven types.
CONSTANT EXPRESSIONS
CONSTANT expressions consist of only constant values. EXAMPLE:
15
20+5/2.0
'X'
INTEGRAL EXPRESSIONS
integral expressions are those which produce integer results after implementing all the automatic and explicit type conversions . EXAMPLE :
m
m*n-5
m*'X'
5+ int(2.0)
where m and n are integer variables.
FLOAT EXPRESSIONS
Float expressions are those which,after all conversions, produce floating-point results.
EXAMPLE:
x+y
x*y /10
5 + float(10)
10.75
where x and y are floating-point variables.
POINTER EXPRESSIONS
Pointer expressions produce address values.example:
&m
ptr
ptr +1
"xyz"
where x is a variable and ptr is a pointer.
RELATIONAL EXPRESSIONS
Relational expressions yield results of type bool which takes a value true or false. Examples:
x<=y
a+b == c+d
m+n>100
When arithmetic expressions are used on either side of a relational operator,they will be evaluated first and then the results compared . Relational expressions are also known as BOOLEAN EXPRESSIONS .
LOGICAL EXPRESSIONS
Logical expressions combine two or more relational expressions and produces bool type results. Examples:
a>b &&x==10
x==10|| y==5
BITWISE EXPRESSIONS
Bitwise expressions are used to manipulate data at bit level.They are basically used for testing or shifting bits .Examples:
x<<3 // shift three bit position to left
y>>1 // shift one bit position to right
Shift operators are often used for multiplication and division by power of two.
ANSI c++ has introduced what are termed as operator keyword that can be used as alternative representation for operator symbols .
An expression is a combination of operators, constants and variables arranged as per the rules of the language.It may also include functions calls which return values.An expression may consist of one or more operands , and zero or more operators to produce a value. expressions may be of the following seven types.
- Constant expressions
- Integral expressions
- Float expressions
- pointer expressions
- Relational expressions
- Logical expressions
- Bitwise expressions
CONSTANT EXPRESSIONS
CONSTANT expressions consist of only constant values. EXAMPLE:
15
20+5/2.0
'X'
INTEGRAL EXPRESSIONS
integral expressions are those which produce integer results after implementing all the automatic and explicit type conversions . EXAMPLE :
m
m*n-5
m*'X'
5+ int(2.0)
where m and n are integer variables.
FLOAT EXPRESSIONS
Float expressions are those which,after all conversions, produce floating-point results.
EXAMPLE:
x+y
x*y /10
5 + float(10)
10.75
where x and y are floating-point variables.
POINTER EXPRESSIONS
Pointer expressions produce address values.example:
&m
ptr
ptr +1
"xyz"
where x is a variable and ptr is a pointer.
RELATIONAL EXPRESSIONS
Relational expressions yield results of type bool which takes a value true or false. Examples:
x<=y
a+b == c+d
m+n>100
When arithmetic expressions are used on either side of a relational operator,they will be evaluated first and then the results compared . Relational expressions are also known as BOOLEAN EXPRESSIONS .
LOGICAL EXPRESSIONS
Logical expressions combine two or more relational expressions and produces bool type results. Examples:
a>b &&x==10
x==10|| y==5
BITWISE EXPRESSIONS
Bitwise expressions are used to manipulate data at bit level.They are basically used for testing or shifting bits .Examples:
x<<3 // shift three bit position to left
y>>1 // shift one bit position to right
Shift operators are often used for multiplication and division by power of two.
ANSI c++ has introduced what are termed as operator keyword that can be used as alternative representation for operator symbols .
No comments:
Post a Comment