Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

right shift in c++

/* C++ Program to demonstrate use of right
   shift operator */
#include <iostream>
using namespace std;
  
int main()
{
    // a = 5(00000101), b = 9(00001001)
    unsigned char a = 5, b = 9;
  
    // The result is 00000010
  
    cout <<"a>>1 = "<< (a >> 1)<< endl;
  
    // The result is 00000100
    cout <<"b>>1 = "<< (b >> 1) << endl;
    return 0;
}
  
// This code is contributed by shivanisinghss2110
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #shift
ADD COMMENT
Topic
Name
9+5 =