Take FREE!! Online AMCAT Mock Test to Crack Wipro NLTH, Capgemini, etc.
Get Off-Campus Placement Jobs Info !!!
Practice Given Here Wipro NLTH Practice Q&A

Program Discussion :: Bitwise Operator

Home > Programs > Bitwise Operator

16 / 15

Write an efficient program to toggle all bits in a given integer number

Answer:

#include 
#include
using namespace std;
int main()
{
    int num, n, newNum;
    /*Reads a number from user*/
   coutnum; 
    /*Reads the bit number you want to toggle*/
    coutn; 
    /* Left shifts 1 to n times then perform bitwise XOR with number and result of above*/
    newNum = num ^ (1 

Asked In ::

Post Your Answer Here:

Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here:



Language:

Post Your Reply Here: