Code Point Blog
Iam presenting here ,all type of knowledge if you want to interest knowing about any topic then click below thumbnail view button and knowing.
Operator : Operators are some symbol which are used to perform a particular tasks.
Arithmetic Operators: Arithmetic operator are Used to perform Arithmetic operation.
Arithmetic Operators are :
Addition (+)
Subtraction (-)
Multiplication(*)
Division (/)
Modulo - remainder of division (%)
2.Assignment Operators: Assignment Operators are used to assign the value.
Assignment Operators are :
Simple Assignment (=)
Add and Assign (+=)
Subtract and Assign(-=)
Multiply and Assign(*=)
Divide and Assign (/=)
Modulo and Assign(%=)
Left Shift and Assign(<<=)
Right Shift and Assign()
Bitwise AND and Assign(&=)
Bitwise XOR and Assign(^=)
Bitwise OR and Assign(|=)
3.Increment and Decrement Operators Increment and Decrement Operators are used to increase or decrease the value.
Increment(++)
Decrement (--)
Increments are two types
1. Pre Increment
2. Post Increment
1. Pre Increment :In pre increment first increase the value after that assign the value.
Example:
#include <stdio.h>
int main()
{
int x=1;
printf("%d",x++);
return 0;
}
output = 1
2. Post Increment : In post increment first assign the value after that increase the value.
Example :
#include <stdio.h>
int main()
{
int x=1;
printf("%d",++x);
return 0;
}
output= 2
Decrements are Two Types
1. Pre Decrement
2. Post Decrement
1. Pre Decrement :In pre Decrement first decrease the value after that assign the value.
Example :
#include <stdio.h>
int main()br
int a=2;
printf("%d",--a);
return 0;
}
output =1
2. Post Decrement :In post Decrement first assign the value after that decrease the value.
Example :
#include <stdio.h>
int main()
{
int a=2;
printf("%d",a--);
return 0;
}
output=2
3.Comparison Operators :Comparision or Relational operator are use to compare two values,if return either true 1 and false 0.
'==' (Equal to)
'!=' (Not equal to)
'>' (Greater than)
'<' (Less than)
'>=' (Greater than or equal to)
'<=' (Less than or equal to)
Example :
int a=5,b=6,c=0,d;
1. d= a>=b;
d=false=0.
2. d= a==b;
d= false=0.
3. d= b!=c
d=true=1.
4.Logical Operators :Logical operator are use to join two or more thantwo expression.
There are three type of logical operators
'&&' (Logical AND)
'||' (Logical OR)
'!' (Logical NOT)
Logical AND :Operator return True '1' when all the input are True (1) otherwise False (0).
A B A&&B
0 0 0
0 1 0
1 0 0
1 1 1
Example :
d=a&&c;
(1&&0)
d= false =0.
Logical OR : Operator return 0 when all the inputs are 0 therwise 1.
A B A||B
0 0 0
1 0 1
0 1 1
1 1 1
Example :
d= a||b;
(1&&1)
d= true=1
Logical NOT :It in word the input that is if input one than it will return 0 and if the input are 0 than it will return 1
A B
0 1
1 0
Example :
e= !c;
e= true=1
Bitwise Operators :Bitwise operator work on bit level that operator is evaluated on each bit of the variable. there are different types of bitwise operator.
1. Bitwise operator AND (&)
2. Bitwise operator OR (|)
3. Bitwise operator left shift (<<)
4. Bitwise operator Right shift (>>)
5. Bitwise operator XOR (^)
6. Bitwise complement (~)
Bitwise operator AND (&) :
0 & 0 = 0
0 & 1 = 0
1 & 0 =0
1 & 1 =1
Ex- int x;
x = 23 & 56;
23= 0000 0000 0001 0111
56= 0000 0000 0011 1000
---------------------------------------------
16= 0000 0000 0001 0000
Bitwise OR(|) :
0 | 0= 0
0 | 1 =1
1 | 1 =1
1| 1 =1
int x;
x= 23 | 56;
23 = 0000 0000 0001 0111
56 = 0000 0000 0011 1000
-------------------------------------------------
63 = 0000 0000 0011 1000
Bitwise operator XOR (^) :
0 ^ 0 = 0
1 ^ 0 = 1
0 ^ 1 = 1
1 ^ 1 = 1
Example :-
int x;
x = 23 ^ 56;
23 = 0000 0000 0001 0111
56 = 0000 0000 0011 1000
----------------------------------------------
47 = 0000 0000 0010 1111
Bitwise operator Right shift (>>) :
int x;
x = 56 >>2;
56 = 0000 0000 0011 1000
14 = 0000 0000 0000 1110
Bitwise operator left shift (<<) :
int x;
x = 56 << 3;
56 = 0000 0000 0011 1000
448 = 0000 0001 1100 0000
Bitwise complement (~) :
int a = 5, b;
b =~5
0000 0000 0000 0101
b =~a 1111 1111 1111 1010
7.Conditional Operator (Ternary Operator) :ditional operator is also known as ternary operator because this operator has three expression.
syntax:-
condition ? Expression 1 : Expression 2
(If condition is true then execute first expression otherwise execute second operation)