Program to toggle the Kth bit of a number in C++: Here we are going to use bitwise operators to toggle Kth bit in the binary representation of a given number.
Problem Statement: To write a C++ program to toggle Kth bit of a number.
Constraints: 1<=n<=100
Example:
Input:
Enter number: 5
Enter k: 2
Output:
original number before toggling: 5
new number after toggling: 7
Algorithm:
C++ Implementation:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer