+ 4
What would be the output ?
// what would be the output ?? #include <stdio.h> int main() { int x; x=~5; printf("%d",x); return 0; }
4 Answers
+ 1
-6
+ 4
Thanxx..i'll check it...đ
+ 3
https://stackoverflow.com/questions/3952122/what-does-tilde-operator-do
Tilde operation is well explained here...
Well you could have tried running the code in code playground..
+ 2
The ~ operator in C++ (and other C-like languages like C and Java) performs a bitwise NOT operation - all the 1 bits in the operand are set to 0 and all the 0 bits in the operand are set to 1. In other words, it creates the complement of the original number.
For example:
10101000 11101001 // Original (Binary 01010111 00010110 // ~Original (Binary
The bitwise NOT operator has an interesting property that when applied on numbers represented by two's complement, it changes the number's sign and then subtracts one (as you can see in the above example)