Logical Operator and conditional operator
Logical Operator
The logical operators are the symbols that are used to combined multiple condition into one condition.
Logical Operator with example
Operator |
|
Example |
&& |
Logical
AND-Return TRUE if all conditions are
TRUE otherwise returns
FALSE |
8<5&&12>10 is FALSE |
|| |
Logical OR-Returns
FALSE if all condition are FALSE otherwise
returns TRUE |
8<5&&12>10 is true |
! |
Logical
NOT-Return TRUE if condition is FALSE and returns FALSE
if it is TRUE |
!(8<5 && a2>10) is true |
Conditional operator
The conditional operator is also called a ternary operator because it requires three operands.
This operator is used for decision making.
Syntax
Condition? TRUE part :FALSE part;
Example-write a code for conditional operator
program-
#include<stdio.h>
void main()
{
int A;
A=(10<15)?printf("True"):printf("False");
}
output:
True
--------------------------------
Comments
Post a Comment