The logical negation operator ! [exclamation] used in C++ and many other languages. However the return value of the operator is overlooked by many people.
The syntax of the operator follows is
! cast-expression
Where, the cast-expression operand must be of scalar type (returning only a single value, not multiple values like an array)
The result is of type int and is the logical negation of the operand:
0 if the operand is nonzero
1 if the operand is zero
To demonstrate the usage of the Logical Negation Operator, the simple program below was written
# include <iostream.h>
# include <conio.h>
void main()
{
clrscr();
cout<<”\nThe expression !0 equals : “<<!0;
cout<<”\nThe expression !0.7 equals : “<<!0.54;
cout<<”\nThe expression !4 equals : “<<!4;
cout<<”\nThe expression !-4 equals : “<<!-4;
getch();
}
The output of the program is an integer value as expected, the negation of the value 0 (Zero) is equal to 1 and the negation operator applied anything else is equal to 0 (Zero)
The expression !0 equals : 1
The expression !0.7 equals : 0
The expression !4 equals : 0
The expression !-4 equals : 0
To summarize, the things to note are that the return type of the operator is int (integer) and the cast-expression operand must be of scalar type
Happy Coding

Explanation is to the point, good post