I have come across a problem involving exclamation marks and integers whilst reading a code in my reference book.
Let us say I have declared an integer variable name
The negation operator (!) simply just reverses the meaning of its operand.
The operand or the expression must be of arithmetic or pointer type. But the operand/result of expression is implicitly converted to data type bool (boolean 0 means false, Non zero means True).
The result is true if the converted operand is false; the result is false if the converted operand is true. The result is of type bool.
so
while(!number)
{
...
}
since variable number is 0 , while(!number) ie, !0 which is 'negation of 0' which is 'TRUE' then it code enters the while loop()