An operator is simply a symbol that is used to perform some mathematical and logical operations.
Ex: + , - , == , = , * etc.
Arithmetic Operator
Ex-
#include<stdio.h>
#include<conio.h>
Void main()
{
int a=10,b=5;
printf(“%d”,a+b); //Addition
printf(“%d”,a-b); //subtraction
printf(“%d”,a*b); //multiplication
printf(“%d”,a/b); //division
printf(“%d”,a%b); //modulus
getch();
}
Relational Operator
Ex-
#include<stdio.h>
#include<conio.h>
Void main()
{
int age=18;
printf((age>=20));
getch();
}
Logical Operator
Ex-
#include<stdio.h>
#include<conio.h>
Void main()
{
int a=2,b=3,c=4,d=5;
printf((a<b&&c<d));
getch();
}
Increment/Decrement Operator
Ex-
#include<stdio.h>
#include<conio.h>
Void main()
{
int a=1;
printf(“%d”,a); // 1
printf(“%d”,++a); //2
printf(“%d”,--a); //1
printf(“%d”,a++); //1 ,2
printf(“%d”,a--); //2 ,1
a+=1; //a=a+1; //2
printf(“%d”,a);
getch();
}
Assignment Operator
Ex-
#include<stdio.h>
#include<conio.h>
Void main()
{
int a=10;
printf(“%s”,a);
getch();
}
Ternary operator
Ex-
#include<stdio.h>
#include<conio.h>
Void main()
{
int age=18;
(age>=18)? printf(“Vote”):printf(“not vote”);
getch();
}
0 Comments