Concept of Logical Operators in C program Example

  1. #include<stdio.h>  
  2. #include<conio.h>  
  3. main()  
  4. {  
  5.     int a,b,c; // local variable assign  
  6.     printf("Enter the number of a\n");  
  7.     printf("Enter the number of b\n");  
  8.     printf("Enter the number of c\n");  
  9.     scanf("%d",&a);  
  10.     scanf("%d",&b);  
  11.     scanf("%d",&c);  
  12.     if(a>b || a>c) // using OR operator if any one condition is true print if statement otherwise else print.  
  13.     {  
  14.         printf("a is greater number\n");  
  15.     }  
  16.     else  
  17.     printf("b and c are greater number of a\n");  
  18.     {  
  19.         if(b>c && b>a) // using AND operator if both condition are true then print if statement otherwise else print.  
  20.         {  
  21.             printf("b is greater number\n");  
  22.         }  
  23.         else  
  24.         printf("a & c are greater number of b\n");  
  25.         {  
  26.             if(c>a != c>b) // using NOT no full-fill any condition always print false like else statement.  
  27.             {     
  28.             printf("c is greater number\n");  
  29.         }  
  30.         else  
  31.         printf("a & b are greater number of c\n");  
  32.         }  
  33.           
  34.         }  
  35.     }