Professional Documents
Culture Documents
Lab1 Operators
Lab1 Operators
int main()
int x,y;
//int a, b;
cin>>x;
cin>>y;
// arithmetic operators
cout<<"sum = "<<x+y<<endl;
cout<<"product= "<<x*y<<endl;
cout<<"division= "<<x/y<<endl;
cout<<"difference= "<<x-y<<endl;
cout<<"remainder = "<<x%y<<endl;
// relational operators
int eql=x==y;
int notEql=x!=y;
int gt=x>y;
int gte=x>=y;
int lt=x<y;
int lte=x<=y;
cout<<"x==y "<<eql<<endl;
cout<<"x!=y "<<notEql<<endl;
cout<<"x>y= "<<gt<<endl;
cout<<"x>=y "<<gte<<endl;
cout<<"x<y "<<lt<<endl;
// logical operators
int lnot=!(x+2>4);
cout<<"!(x+2>4)= "<<lnot<<endl;
cout<<"x++= "<<++x<<endl;
//int ypl=y++;
//cout<<"y++= "<<y++<<endl;
int z= y++*2+x;
cout<<"z= "<<z<<endl;
// precedence operator
// hh
int hd=0xF2F2;
int hd1=hd<<2;
cout<<"hd= "<<hd;