Saturday, July 11, 2020

OPERATOR PRECEDENCE

OPERATOR PRECEDENCE:

()                                                -> Parentheses.

+x, -X, ~X                  -> Unary Plus, Unary minus,  Bitwise No.

**                                            -> Exponentiation (raise to the power).

* / % //                               -> Multiply, divide, Modulo, and Floor 
                                                                                                Division.

+ , -                                  -> Addition and Subtraction.

>>  <<                                 -> Right and Left bitwise .

&&                                         -> Bitwise  "AND"td.

^|                                               -> Bitwise exclusive "OR" and  regular "or".



Example:
        
e=(a+b)* c/d
                                                              #try this using in above the operator 
 e=a+(b*c)/d 
                                                                                precedence.
e=((a+b)*c)/d



       a,b,c,d=2,4,3,5

1.  e=(a+b)* c/d                           e=(2+4)*3/5     
        print(e)                                        e=(6)*3/5 
                                                                    e=18/5  
                                                                    Print(e)  
 OUTPUT:                             3.6                      
3.6

                                              
    2. e=a+(b*c)/d                                  e=2+(4*3)/5
         print(e)                                            e=2+(12)/5
                                                                         e=2+2.4
                                                                         print(e)
                                                                        4.4                                                                                                OUTPUT:          
     4.4
    
 3  e=((a+b)*c)/d
        print(e)
                                                  # YOU  TRY   😜😜                         
OUTPUT:
3.6


No comments:

Post a Comment