Search
 
SCRIPT & CODE EXAMPLE
 

CPP

right shift in c++

/* C++ Program to demonstrate use of left shift 
   operator */
#include<stdio.h>
int main()
{
    // a = 5(00000101), b = 9(00001001)
    unsigned char a = 5, b = 9; 
  
    // The result is 00001010 
    printf("a<<1 = %d
", a<<1);
    
    // The result is 00010010 
    printf("b<<1 = %d
", b<<1);  
    return 0;
}
Comment

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
Comment

c++ shift array to the right

	// Shift array elements to right
	const int SIZE = 9;
	int arr[SIZE]={1,2,3,4,5,6,7,8,9};

	int last = arr[SIZE - 1];		
	for (int i = SIZE - 1; i > 0; i--)	
		arr[i] = arr[i - 1];		
	
	arr[0] = last;
Comment

PREVIOUS NEXT
Code Example
Cpp :: Maximum sum of non consecutive elements 
Cpp :: stl map remove item 
Cpp :: custom slider cpt wordpress theme 
Cpp :: create vector of specific size c++ 
Cpp :: c++ function pointer variable 
Cpp :: copy vector c++ 
Cpp :: C++ function inside main 
Cpp :: phi function 
Cpp :: ? in cpp 
Cpp :: kadane algorithm with negative numbers included as sum 
Cpp :: even and odd numbers 1 to 100 
Cpp :: c++ char 
Cpp :: bitmap 
Cpp :: inverted triangle c++ 
Cpp :: book allocation problem in c++ 
Cpp :: C++ Vector Initialization method 03 
Cpp :: how to get characters through their ascii value in c++ 
Cpp :: surf interpolation matlab 
Cpp :: c++ round number to 2 decimal places 
Cpp :: remove a element from an array c++ 
Cpp :: cpp split bits 
Cpp :: increment integer 
Cpp :: class how to call main method inheritance in c++ 
Cpp :: c++ constructor inheritance 
Cpp :: how to type cast quotient of two integers to double with c++ 
Cpp :: sfml time set 
Cpp :: convert c++ to c language 
Cpp :: what type is this c++ 
Cpp :: max in c++ with three elements 
Cpp :: GoPro camera for kids aus 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =