C tutorial last serieswe  had known about Relational operators  | Today this tutorial series we know about Logical operators | When we two variables, constants or operands to compare owed to us Relational operators of used but when we have more than one condition to check to do what no one will do ? Let us know in this tutorial series since two or more condition to compare what would it be like ?

Logical operators in C
Logical Operators use more than two or expression or condition is to compare | The operators more than two or expressions to combine ( the link) and it is a condition that makes
In other words, the operators use logical operation to perform is to

Let's example to understand | Suppose a company vacancy that arises out and that vacancy for Minimum Qualification Graduation should as well Graduation of 60% is required to be above brands now one here perform logic which will be the first to check out what will candidates has Graduation qualification and if Graduation qualification , then check will do its brands 60% is equal to or greater than if both condition true is then further process follow otherwise it was sort he will | On Logical AND condition apply happening |
( candidates_qualification > = Graduation && graduation_marks > = 60)
Under the table in Logical operators list are |

Operators
Description
Example
&&
The operator called the Logical AND operator | The operator used check two expression of output to is to | In that both expression of output true only if it is true will return would otherwise False return | As A has value 5 store and B have the value is 3 store |
((A * B) == 15) && ((A + B) == 8)
Return true
||
The operator of the called Logical OR operator | The operator used check two expression of output to is to | In both that one of the expression of the output true then it would be true return would otherwise False return will | As A has value 5 store and B have the value 3 store is |
((A * B) == 15) || ((A + B) == 7)
Return true
!
The operator of the Logical NOT operator called | The operator used any Logical state the reverse is to | If no condition true then Logical NOT operator him false makes | As A has value 5 store and B have the value 3 store is |
! ((A * B) == 15) && ((A + B) == 8)
return false


















Example program of Logical Operators in C
#include

int main ()
{
   int a = 25, b = 36;

   // Logical AND operator
   if ( a b || a! = 0)
   {
      printf ( "one condition is true \ n");
   }

   // Logical NOT Operator
   if (! (a> b || a! = 25))
   {
      printf ( "Both conditions are false but it is inverted as true \ n");
   }

   return 0;
}
Output

Both condition are true
one condition is true
Both conditions are false but it is inverted as true






Explanation of the above program
The above program in just two variables to declare and initialize has that value , respectively 25 and 36 is
·    The first program in the if condition is imposed in this check what has been a, b is smaller than if the condition true is if the next condition check because Logical AND operator all the condition true is only true block will be at or false block will be in |
·    Then click Next condition clasped in which they check what has been a, b is greater than or a, 0 one of both that is equal to the condition right then is true block print will or false print will |
·    The condition in which check what is going to be a, b is greater than a, 25 is not the same as if both condition false then Logical Not operator (!) False to True to convert will have and if both condition true is the condition revert will be condition false will be
·     
Truth table for Logical AND operator

Condition1
      Condition2
Condition1 && Condition2
True
     True
True
True
   False
False
False
True
False
False
False
False

Truth Table for Logical OR Operator

Condition1
Condition2
Condition1 || Condition2
True
True
True
True
False
True
False
True
True
False
False
False

Truth Table for Logical NOT 
operator

Condition
Output
True
False
False
True

Thank you for reading this tutorial.


Post a Comment

Please do not any spam link in the comment

Previous Post Next Post