knowledgediarybd.com

Your Virtual Knowledge Campus

Operators Operands and Expression In C++

operators operands & expression in c++C++ Operators , Operands and Expression  are the sets of Element  that  perform a lot of  special work in  C++ programming.

 For example : An assignment operator  the equals sign ( = ) is use to assign a value to a variable.which is known as assignment operator.

We use a division sign ( / ) to divide two number together and   it is known as an arithmetic operator.

 

Operators ,Operands & Expression in c++:

Operator can’t  do any things without operand and operand is that on which an operator work. For example: 12/ 3 =4  Here,12 , 3 and 4 are operand &  division  sign ( / ), equal sign(=) are operators and 12/3=12 is an expression .

Dear learner in this tutorial  i discussed details about of C++ Operators, operands  and  Expression .  I hope everyone must be benefited  form this tutorial.

Various Types of C++ operators:

1. Arithmetic Operators:

List of  Arithmetic operators in c++:

Operator with expression
Name
Description
Example
Result
a+ b
Addition
Sum of a and b
5+3
8
a-b
Subtraction
Difference of a & b
6-4
2
a*b
Multiplication
Product of a and b
8*8
64
a/b
Division
Quotient of a and b
25/5
5
a%b
Modules/mod
Remainder of a divided by b
7%3
1
-a
Negation
Opposite of a
-5
-5
x . y
Concatenation
Concatenate of two string
“Hell” . “World “
Helloworld

2. Decrementing/Incrementing Operators in C++:

Operator with expression
Name
Description
++a
Pre-increment
Increment a by one, then returns a.
a++
Post-increment
Return a, then increment a by one
–a
Pre-decrement
Decrements a by one, then return a.
a–
post-decrement
Return a then decrements a by one.

3. Logical Operators in c++:

List of  logical Operators in c++:

Operator
Name
Description
Example with expression
a and b
And
True if both a and b are true.a=5,b=2(a<8 and b>1 )thenreturn true.
a or b
Or
True if one  or both a & b are truea=7,b=9if (a==7 or b==6)then return true.
a xor b
Xor
True if one Or   a or b is true but not both.

a=3,b=5

If(a==3 xor b=5)

return false.Because

both are true.

a && b
Logical And
True if both a and b are true.a=8,b=4if (a<9 && B>3)then return true.
a || b
Logical Or
True if one  or both a & b are true.a=2,b=9if( a==2 || b==9)then return true
! a
Not
True if a is not truea=10,b=12if !(a==b) then returntrue.

4. Assignment Operators:

An assignment operator  the equals sign ( = ) is use to assign a value to a variable.which is known as assignment operator.

For example:

Assignment Operators with expression
Description
a=a
Here left operand get the value of the expression on the right side
a+=b Or a=a+b
Addition
a-=b Or a=a-b
Subtraction
a*=b Or a=a*b
Multiplication
a /=b Or a= a /b
Division
a%=b Or a= a%b
Modulus/mod
x.=y Or a=a .b
Concatenate two strings

 5. Comparison Operators in c++

Comparison operators help you to compare between  two values:

List of Comparison Operators in c++:

Operator with expression
Name
Description
a = = a
Equal
True if a is equal to b
a = = = a
Identical
True if a is equal to b and they are same in type
a < > b
Not equal
True if a is not equal to b
a > b
Greater than
True if a is greater than b
a < b
Less than
True if a is less than b
a!=b
Not equal
True if a is not equal to b
a!== b
Not identical
True if a is not equal to b or they are not same in type
a <= b
Less than or equal to
True if a is less than or equal to b
a >= b
Grater than or equal to
True if a is greater than or equal to b

 

Related Post or You may like:

knowledgediarybd.com © 2017
shares