Logical Not ! operator in C with Examples
Last Updated :
15 Oct, 2019
! is a type of Logical Operator and is read as “NOT” or “Logical NOT“. This operator is used to perform “logical NOT” operation, i.e. the function similar to Inverter gate in digital electronics.
Syntax:
!Condition
// returns true if the conditions is false
// else returns false
Below is an example to demonstrate ! operator:
Example:
#include <stdio.h>
int main()
{
int a = 0;
if (!a)
printf ( "Condition yielded True\n" );
else
printf ( "Condition yielded False\n" );
a = 1;
if (!a)
printf ( "Condition yielded True\n" );
else
printf ( "Condition yielded False\n" );
return 0;
}
|
Output:
Condition yielded True
Condition yielded False
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...