0
590views
What is a Logical Operators ?
1 Answer
written 2.9 years ago by |
Logical Operator
consider x = 5
1. and Operator returns true of the both the conditions are true
for e.g:- print( x > 3 && x <6 )
Output:- True as value of x is in between 3 and 6
2. or Operator return true even if one of the statement is true
for e.g:- print( x > 6 && x < 10)
Output:- True as value of x is less then 10
3. not Operator return false if the result is true
for e.g:- print(not(x >10 ))
Output:- True as value of x is less then 10 the result would be false but operator would
return opposite value of the result.
#include <stdio.h>
int main() {
int x = 5;
if ( x > 3 && x <6 ) {
printf("True x is greater then 3 and less then 6\n" );
}
if ( x > 6 || x < 10 ) {
printf("True x is less 10 condition satisfied and \n" );
}
if(!x ==0){
printf("not of x is 0");
}
/* lets change the value of a and b */
}