Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- // All logical operators which commonly used in decision making
- int main()
- {
- /*logical operator returns either 0 or 1
- depending upon whether
- expression results true or false.*/
- int a,b,c,result;
- printf(" Enter value of a b c: \n");
- scanf("%d %d %d",&a,&b,&c);
- result = (a == b) && (c > b);//Logical AND. True only if all operands are true
- printf("(a == b) && (c > b) is %d \n", result);
- result = (a == b) && (c < b);
- printf("(a == b) && (c < b) is %d \n", result);
- result = (a == b) || (c < b);//Logical OR. True only if either one operand is true
- printf("(a == b) || (c < b) is %d \n", result);
- result = (a != b) || (c < b);
- printf("(a != b) || (c < b) is %d \n", result);
- result = !(a != b);//Logical NOT. True only if the operand is 0
- printf("!(a == b) is %d \n", result); /* !(a != b) evaluates to 1 because operand (a != b) is 0 (false).
- Hence, !(a != b) is 1 (true).*/
- result = !(a == b);
- printf("!(a == b) is %d \n", result); /* !(a == b) evaluates to 0 because (a == b) is 1 (true).
- Hence, !(a == b) is 0 (false). */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement