Wednesday, May 20, 2020

Assignment operators in C++


  • Program :

#include <iostream>
using namespace std;

int main() {
  cout <<"\n----------------ASSIGNMENT OPERATORS----------------\n";
  int a = 5;
  int b = 10;
  b += 3;
   int c = 15;
  c -= 3;
  int d = 20;
  d *= 3;
   double e = 25;
  e /= 3;
  int f = 30;
  f %= 3;
  int g = 35;
  g &= 3;
  int h = 40;
  h |= 3;
  int i = 45;
  i ^= 3;
   int j = 50;
  j >>= 3;
   int k = 55;
  k <<= 3;
  cout <<"\n a = "<< a;
  cout <<"\n a += "<< b;
  cout <<"\n a -= "<< c;
  cout <<"\n a *= "<< d;
  cout <<"\n a /= "<< e;
  cout <<"\n a %= "<< f;
  cout <<"\n a &= "<< g;
  cout <<"\n a |= "<< h;
  cout <<"\n a ^= "<< i;
  cout <<"\n a >>= "<< j;
  cout <<"\n a <<= "<< k;
  return 0;
}




  • Output :


No comments:

Post a Comment

Function Overloading in C++

https://monitechvenkat1620.blogspot.com Program : #include <iostream> using namespace std; int c(int x, int y) {   return...