logical operators and Increment operator



         basically, logical operators use for checking the given two or more condition this operator its contains and, or, not
AND(&&)
now we will see AND operators. normally and operators used for checking the condition, AND means our given the condition both correct that's the time it will execute our program. otherwise, it doesn't execute


                                     
  
OR(||):-
     
       now this type either one condition is correct it will execute your program.
NOT(!)
       this used when we want to reverse the value of the expression. that is it makes true statements false and vice versa.

input 1

 input 2

  AND(&&)                     

 OR(||)

  NOT(!)                     

  0

 0

      0

  0 

 1 

  0

  1

      0

  1

 0

 1

 0

      0

  1

 

  1

  1

      1

  1

 

 
these are some important values.in here we have given 0,1, you have to choose anyone 0 or 1 is true, then go through the condition you can easily understand. 

example:

 #include<stdio.h>                     

 #include<conio.h>
int main()
{
 
printf("(5<=8)&&(4<=2):%d",((5<=8)&&(4<=2)));
 
printf("\n(5>=3)||(6<4):%d",((5>=3)||(6<4)));
 
printf("\n !(7==7):%d",!(7==7));

  return 0;


}


OUTPUT:

OUTPUT


    (5<=8)&&(4<=2):1
    (5>=3)||(6<4):1
    !(7==7):0



In this program, we have directly declared all the logical operators in a print statement. First, our print statement is about AND operator. (5<=8) our first condition is true, then our second condition  (4<=2) also true, so our output is 1. our second print statement we have declared OR  operators, we already have known either any one condition has true it will give our output. so it gives 1, the last one NOT operator, suppose our condition has true it will give true opposite value .so it gives 0 value.


INCREMENT AND DECREMENT:

       increment operator and decrement operator normally used for incrementing or decrementing some values on your previous value.


               
          here is the symbol of increment and decrement operators.

   example program for incrementing and decrementing operators.


 #include<stdio.h>                     

 #include<conio.h>
int main()
{
 
int a=10;

 printf("a++:%d\n",a++);               

printf("a--:%d\n",a--);

printf("++a:%d\n",++a);

printf("--a:%d\n",--a);

 

return 0;

 

}


OUTPUT :

OUTPUT


     a++:10
     a--:10
     ++a:11
     --a:9    

 

No comments:

Post a Comment