Frame a class Register8 with the following:
value
void setBit(int pos)
void clearBit(int pos)
void toggleBit(int pos)
unsigned char getValue() const
The input will contain:
n
Example Input:
3 set 0 set 2 toggle 2
Output:
1
Here, n = 3. Operations: set bit 0 → 00000001 (1), set bit 2 → 00000101 (5), toggle bit 2 → 00000001 (1).
Input:
4 set 7 set 0 clear 7 toggle 1
3
Explanation: After operations, the register is 00000011 (decimal 3).
Test Cases
Test Results
Input
Expected Output