Operators


#include <stdafx.h>  
#include <iostream>

using namespace std; 

int main() 
{  
  int a=5,b=5,c;  /*  = is an assignment operator.Other assignment operators are +=,-=,*=,/=,%=,<<=,>>=,&=,^= and |= */
  c=a+b;      /* + is an arithmetic operator,other arithmetic operators are -,*,/,%,++ and --   */
  cout<< "Sum of a and b= " << c <<endl;

  if(c==10)
  {
    cout<< "Use of relational operator" << endl;  /* == is a relational assignment operator,other relational operators are !=,<,>,<= and >=  */
  }

  c=a&b;      /* & is a bitwise AND operator.Other bitwise operators are |,^,~,<<,>> and >>> */  
  cout<< "Binary AND value of a and b= " << c << endl;

  bool b1=true,b2=false;
  cout<< "Logical AND value of b1 and b2= " << (b1&&b2<< endl; /* && is a logical AND operator.Other logical operators are || and ! */

  return 0;  

}

Output:
Sum of and b= 10
Use of relational operator
Binary AND value of a and b= 5
Logical AND value of b1 and b2= 0