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 201 views
1 answer 261 views
1 answer 280 views
1 answer 161 views
1 answer 282 views
...