
Bit toggle of 31 isn't 95, it's 63.
The example with input of 31 is wrong, toggling the 6th bit. That got me stuck in a figure it out loop for a good while lol
Please fix this
#include <stdio.h>
int toggleFifthBit(int n) {
// Write your code here
n ^= (1 << 5);
return n;
}
int main() {
int n;
scanf("%d", &n);
printf("%d", toggleFifthBit(n));
return 0;
}When i use uint8_t instead of int.. the expected output is failed ... when the input is 31... what is the reason

uint8_t has only 8 bits, but bit index 31 is out of range, so 1U << 31 is 32-bit, assigning back to 8-bit truncates and hence the toggling fails