How to multiply number by 2 using bitwise operators in C++

1 Answer

0 votes
#include <iostream>

int main(void) {
    int n = 8;
     
    std::cout << n << " * 2 = " << (n << 1);
       
    return 0;
}
    
       
       
       
/*
run :
   
8 * 2 = 16
   
*/

 



answered Oct 6, 2021 by avibootz

Related questions

1 answer 194 views
1 answer 252 views
1 answer 270 views
1 answer 157 views
1 answer 275 views
...