/*
//Operator
// WAP to represent Arithmetic operator
// 1. Addition operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a=10;
int b=20;
int c=a+b;
cout<<"Sum of (a and b) is : "<<c;
getch();
}
//2. Substraction Operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"Enter value of A and B : ";
cin>>a>>b;
int c=a+b;
cout<<"Sum of two numbers is : "<<c;
getch();
}
// WAP to represent multiplication operator;
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
cout<<"Enter value of A , B and C : ";
cin>>a>>b>>c;
int d=a*b*c;
cout<<"Multiplication of three nos is : "<<d;
getch();
}
// WAP to represent division operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"Enter two value : ";
cin>>a>>b;
int c=a/b;
cout<<"Division of "<<a<<"and "<<b<<" is : "<<c;
getch();
}
// WAP to represent Modulo operator;
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
cout<<"Enter two nos : ";
cin>>a>>b;
c=a%b;
cout<<"RESULT : "<<a<<" % "<<b <<" = " <<c;
getch();
}
// Relational Operator
// Greater than
// WAP to represent Greater than operator....
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
cout<<"Enter two nos to check greatest nos b/w them : ";
cin>>a>>b;
if(a>b)
cout<<"A is the greatest";
else
cout<<"B is the greatest";
getch();
}
// To represent less than operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"Enter two nos : ";
int a,b;
cin>>a>>b;
a<b?cout<<"A is the lowest":cout<<"B is the lowest";
getch();
}
// To represent Greater than or equal to operator
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
cout<<"Enter Two Nos : " ;
cin>>a>>b;
if(a>b)
cout<<"A is the greater than B";
else if(a==b)
cout<<"A is equal to B";
else
cout<<"B is greater than A";
getch();
}
// To represent Less than or equal to operator
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
cout<<"Enter Two Nos : " ;
cin>>a>>b;
if(a<b)
cout<<"A is the less than B";
else if(a==b)
cout<<"A is equal to B";
else
cout<<"B is less than A";
getch();
}
// To represent Equal to equal to operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"Enter two value: ";
cin>>a>>b;
if(a==b)
{
cout<<"A is equal to B ";
}
getch();
}
// To represent Not equal to operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"Enter two value: ";
cin>>a>>b;
if(a|=b)
{
cout<<"A is not equal to B ";
}
getch();
}
// Logical operator
// Logical AND
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
cout<<"Enter value of a and b: ";
cin>>a>>b;
c=a&&b;
cout<<"A logical AND B = "<<c;
getch();
}
// Logical OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
cout<<"Enter value of a and b: ";
cin>>a>>b;
c=a||b;
cout<<"A logical OR B = "<<c;
getch();
}
// Logical NOT
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<"Enter value of A =";
cin>>a;
b=!a;
cout<<"A logical NOT = "<<b;
getch();
}
// WAP to represent pre increament .
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
b=++a;
cout<<"a="<<a<<"\nb="<<b ;
getch();
}
// WAP to represent pre Decreament .
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
b=--a;
cout<<"a="<<a<<"\nb="<<b ;
getch();
}
// WAP to represent Post increament .
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
b=a++;
cout<<"a="<<a<<"\nb="<<b ;
getch();
}
// WAP to represent post decreament .
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
b=a--;
cout<<"a="<<a<<"\nb="<<b ;
getch();
}
//Type 1
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
a++;
++a;
a++;
--a;
cout<<"a = "<<a;
getch();
}
//Type
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
cout<<"a = "<<++a;
getch();
}
//Type
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
cout<<"a = "<<--a;
getch();
}
//Type
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
cout<<"a = "<<a++;
getch();
}
//Type
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
cout<<"a = "<<a--;
getch();
}
//Type
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
cout<<++a<<","<<a++<<","<<++a;
getch();
}
//Type
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
cout<<--a<<","<<a--<<","<<--a;
getch();
}
//Type
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
b=a++ + ++a + a++ + ++a;
cout<<b;
getch();
}
//Type
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
b=a++ + --a + a++ + ++a;
cout<<b;
getch();
}
//Type
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
b=a++ - --a + a++ + ++a;
cout<<b;
getch();
}
// Bitwise Operator
// WAP to represent Bitwise AND operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=15;
b=5;
c=a&b;
cout<<c;
getch();
}
// WAP to represent Bitwise AND operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=-15;
b=5;
c=a&b;
cout<<c;
getch();
}
// WAP to represent Bitwise AND operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=-15;
b=-5;
c=a&b;
cout<<c;
getch();
}
// WAP to represent Bitwise OR operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=15;
b=5;
c=a|b;
cout<<c;
getch();
}
// WAP to represent Bitwise OR operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=-15;
b=5;
c=a|b;
cout<<c;
getch();
}
// WAP to represent Bitwise OR operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=-15;
b=-5;
c=a|b;
cout<<c;
getch();
}
// WAP to represent Bitwise XOR operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=15;
b=5;
c=a^b;
cout<<c;
getch();
}
// WAP to represent Bitwise XOR operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=-15;
b=5;
c=a^b;
cout<<c;
getch();
}
// WAP to represent Bitwise XOR operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=-15;
b=-5;
c=a^b;
cout<<c;
getch();
}
// WAP to represent Bitwise NOT
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=5;
b=~a;
cout<<b;
getch();
}
// WAP to represent Bitwise NOT
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
a=-5;
b=~a;
cout<<b;
getch();
}
// O/p: 4
// Bitwise Shift
// Left shift
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
a=15;
b=a<<2;
cout<<b;
getch();
}
// O/p : 60
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
a=5;
b=a<<2;
cout<<b;
getch();
}
// O/p : 20
// Right shift
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
a=15;
b=a>>2;
cout<<b;
getch();
}
// O/p : 3
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
a=5;
b=a>>2;
cout<<b;
getch();
}
// O/p : 1
// sizeof() operator
// WAP to represent sizeof() operator
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a;
cout<<sizeof(a);
getch();
}
O/p: 2
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"char :"<<sizeof(char);
cout<<"\nint :"<<sizeof(int);
cout<<"\nlong :"<<sizeof(long);
cout<<"\nfloat :"<<sizeof(float);
cout<<"\ndouble :"<<sizeof(double);
cout<<"\nlong double :"<<sizeof(long double);
getch();
}
O/p:
char : 1
int : 2
long : 4
float : 4
double : 8
long double : 10 */