In this post,you will read about C/C++ Operators.
We use the Operators almost in every C/C++ program.It is very useful in C/C++ language.
Arithmetic Operators
Arithmetic operators are use for perform arithmetic operations.
We use the Operators almost in every C/C++ program.It is very useful in C/C++ language.
Operators in C | My CS Tutorial |
C/C++ Operators
In C/C++ language, Operators are some symbols which tell the Compiler(computer) to exicute proper operation as mathematical or logical operations.
C operators are classified in eighth categories which are following...
- Arithmetic Operator
- Logical Operator
- Assaiment Operator
- Relational Operator
- Increment and Decrement Operator
- Conditional Operator
- Bitwise Operator
- Special Operator
Arithmetic Operators
Arithmetic operators are use for perform arithmetic operations.
All arithmetic operators are use in C/C++ language as +,-,*,/,%
Operator meaning
+ addition
- subtraction
* multiplication
/ division
% modulo divison
(Reminder)
Examples:
x+y // for addition
x-y // for subtraction
x*y // for multiplication
x/y // for devide
x%y // for reminder
In C/C++ language, we use logical operators when we exicute more than one condition. Logical operators provide three operators which are as follows...
Operator Meaning
&& logical AND
|| logical OR
! logical NOT
Operators Description
&& It is use for performing
logical conjunction of
two expressions.
|| It is use for performing
logical disjunction of two
expressions.
! It is use for performing
negation on two expressions.
Example:
x<25||x>50
Assaiment operators is a type of operators which is use for assign the result of an expression.'=' is assaiment operator.
In assaiment operators,many operators involved which are as follows...
Operators meaning
= assign
+= increment then assign
-= decrement then assign
*= multiple then assign
/= divide then assign
%= modul then assign
<<= shift left and assign
&= bitwise AND assign
>>= shift right and assign
^= bitwise exclusive OR and essign
|= bitwise inclusive OR and essign
Relational operators are important operators in c/c++ language. It is use for comparing two values in a C/ C++ program.
Which are as follows...
Operators meaning
== for equal
!= for not equal
< less than
> greater than
<= less than or equal
>= greater than or equal
Example:
if(x==y)
if(x!=y)
These operators are use for increase or decrease the value.Increment operator adds 1 and decrement operator subracts 1 from operand.
It is mostly use in loops.
Operator meaning
++ increment operator
-- decrement operator
Example:
for(i=1;i<=10;i++)
for(i=10;i>=1;i--)
? : conditional operator
Syntax:
expression1?expression2:expression3;
Example:
m=(x>y)?x:y;
Bitwise operator is a powerfull feature of C/C++ language which is use for manipulate(test) the bits and it shift the bits on left or right.It have many operators which are as follows...
Operator meaning
<< left shift
>> right shift
& AND
| OR
^ XOR
~ ones complement
Special operators are very usefull.It has three operators which are following.....
Operator meaning
size of () return the size of a memory location
& return the address of a memory location
* pointer to a variable
Example:
a=sizeof(x);
b=sizeof(float);
All these operators are use in C/C++ language. Every operator is important in C programing language.
I hope that you will understand properly.If you have any problem(question) so you can give comment in bellow.
(Reminder)
Examples:
x+y // for addition
x-y // for subtraction
x*y // for multiplication
x/y // for devide
x%y // for reminder
Logical Operators
In C/C++ language, we use logical operators when we exicute more than one condition. Logical operators provide three operators which are as follows...
Operator Meaning
&& logical AND
|| logical OR
! logical NOT
Operators Description
&& It is use for performing
logical conjunction of
two expressions.
|| It is use for performing
logical disjunction of two
expressions.
! It is use for performing
negation on two expressions.
Example:
x<25||x>50
Assaiment Operators
Assaiment operators is a type of operators which is use for assign the result of an expression.'=' is assaiment operator.
In assaiment operators,many operators involved which are as follows...
Operators meaning
= assign
+= increment then assign
-= decrement then assign
*= multiple then assign
/= divide then assign
%= modul then assign
<<= shift left and assign
&= bitwise AND assign
>>= shift right and assign
^= bitwise exclusive OR and essign
|= bitwise inclusive OR and essign
Example:
sum +=i;
Relational Operators
Relational operators are important operators in c/c++ language. It is use for comparing two values in a C/ C++ program.
Which are as follows...
Operators meaning
== for equal
!= for not equal
< less than
> greater than
<= less than or equal
>= greater than or equal
Example:
if(x==y)
if(x!=y)
Increment or Decrement
These operators are use for increase or decrease the value.Increment operator adds 1 and decrement operator subracts 1 from operand.
It is mostly use in loops.
Operator meaning
++ increment operator
-- decrement operator
Example:
for(i=1;i<=10;i++)
for(i=10;i>=1;i--)
Conditional Operator
It is use for make a conditional statement. It has three conditions in a statement.( ? : ) use in conditional operator.
Operator meaning
Syntax:
expression1?expression2:expression3;
Example:
m=(x>y)?x:y;
Bitwise Operator
Bitwise operator is a powerfull feature of C/C++ language which is use for manipulate(test) the bits and it shift the bits on left or right.It have many operators which are as follows...
Operator meaning
<< left shift
>> right shift
& AND
| OR
^ XOR
~ ones complement
Special Operators
Special operators are very usefull.It has three operators which are following.....
Operator meaning
size of () return the size of a memory location
& return the address of a memory location
* pointer to a variable
Example:
a=sizeof(x);
b=sizeof(float);
All these operators are use in C/C++ language. Every operator is important in C programing language.
I hope that you will understand properly.If you have any problem(question) so you can give comment in bellow.
No comments:
Post a Comment