Page 129 - computer science (868) class 11
P. 129

2.  10 | 7
                       10 = 1010 (In Binary)
                       7 = 0111 (In Binary)
                       Bit Operation of 10 | 7
                               1010
                       |     0111
                             00001111                       which is 15 in decimal
                 Ans.  15
                   3.  !5
                       5 = 0101 (In Binary)
                       !(5) = 1010                          which is -5 in decimal

                 Ans.  -5
                   4.  5 ^ 3
                       5 = 0101 (In Binary)
                       3 = 0011 (In Binary)
                       Bit Operation of 5 ^ 3
                           0101
                       ^  0011
                           0110                             which is 6 in decimal
                 Ans.  6
                   5.  ∼47
                       47 = 101111 (In Binary)
                       Bitwise complement Operation of 47
                      ∼ 101111
                          010000 = 16 (In decimal)

                 Ans.  16
                   6.  12 | 25
                       12 = 01100 (In Binary)
                       25 = 11001 (In Binary)
                       Bitwise OR Operation of 12 and 25
                           01100
                       | 11001
                           11101  which is 29 in decimal
                 The following program demonstrates the use of bitwise operators:
























                                                                                                                       127
                                                                                               Variables and Expressions  127
   124   125   126   127   128   129   130   131   132   133   134