What is operator -
An operator is a symbol that specific
that operator an activity to be perform.
Classification of operators are given below -
Arithmetic operator -
The operator that are used to perform
arithmetic operator such as addition,
Subtraction, multiplication, etc are called arithmetic operator.
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int a, b, c;
Printf("Enter the value of a and b");
Scanf("%d%d", &a, &b);
C=a+b;
Printf("value of c", c);
getch();
}
Assignment operator -
An operator which used to copy the data or results of an expression. assignment operator copy or storing is to a memory is called assigning. The assignment is denoted by single.
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k, r;
k=20;
r=k;
Printf("Enter the value of k =%d",k);
Printf("Enter the value of r =%d",r);
getch();
}
Increment operator -
There are two types -
1. Post increment operator -
If the increment operator "++" his placed the operand than then the operand is called post increment.
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k=20;
k++;
Printf("Enter the value of k =%d",k);
getch();
}
2. Pre increment operator -
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k=20;
++k;
Printf("Enter the value of k =%d",k);
getch();
}
Decrement operators -
"--" is a decrement operators. It Decreament the value of operand by one. These are two types -
1. Post decrement operator -
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k=20;
k--;
Printf("Enter the value of k =%d",k);
getch();
}
2. Pre decrement operator -
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k=20;
--k;
Printf("Enter the value of k =%d",k);
getch();
}
Relational operator -
The representation operator is also called compression operator are used
to to fine the relationship between two
Operand are called representation
Operator.
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k=20 r=10;
If(k>r)
{
Printf(" This value is greater ");
}
Else {
Printf("this value is not greater");
}
getch();
}
Logical operator -
As we have logical get such as AND, OR,
And NOTE. Whose output is one or arrow one or NOT. He also have logical operator after evaluate expression consisting of logical operator.
Results in either true or false.
Conditional operator -
It is also called ternary operator as the name of indiget an operator that operator on three operand.
Example-
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k,r,g;
Printf("Enter the value of k and r");
Scanf("%d%d",&k, &r);
G= (k>r)?k:r;
Printf("value of G=%d",G);
getch();
}
Bit Wise operator -
The data is store in the memory enterm
Of binary digits such as 0 and 1. Sometimes it's may be necessary to manipulate. These operator that are used manipulate the bit are called bit wise operator.
1. Bit wise AND -
If the corresponding bit position in both the operand are one then AND operator results in one. Otherwise AND operator results in zero.
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k,r,g;
g = k&r;
Printf("%d&%d=%d",k,r,g);
getch();
}
2. Bit wise OR -
If the corresponding bit position in both the operand are zero then OR operator results in zero . Otherwise OR operator results in one.
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k,r,g;
g = k/r;
Printf("%d/%d=%d",k,r,g);
getch();
}
3. Bit wise X-OR -
It the position of both operand are different then operation results in one otherwise results in zero.
Example -
# include <stdio.h>
#include <conio.h>
Void main ()
{
Int k,r,g;
g = k^r;
Printf("%d^%d=%d",k,r,g);
getch();
}
No comments:
Post a Comment