Page 39 - 6437
P. 39

ine    /=      erator       ample, alue  f        1

                                                        Op          Ex
                                    ine    %=      erator       ample, alue  f        1


                            Line 9 - &= Operator Example, Value of c = 2

                            Line 10 - ^= Operator Example, Value of c = 0
                            Line 11 - |= Operator Example, Value of c = 2


                          Misc Operators ↦ sizeof & ternary
                          Besides the operators discussed above, there are a few other important operators including
                   sizeof and ? : supported by the C Language.


                         Oper          Description                                      Example
                  ator

                         sizeo         Returns the size of a variable.                  sizeof(a), where a is
                  f()                                                            integer, will return 4.


                         &             Returns the address of a variable.               &a;    returns   the
                                                                                 actual   address   of   the
                                                                                 variable.



                         *             Pointer to a variable.                           *a;


                         ? :           Conditional Expression.                          If  Condition  is  true
                                                                                 ?  then  value  X  :  otherwise
                                                                                 value Y


                          Example
                          Try following example to understand all the miscellaneous operators available in C:



                 #include <stdio.h>


                 main()
                 {
                    int a = 4;

                    short b;

                    double c;
                    int* ptr;
                                                                                                      41
   34   35   36   37   38   39   40   41   42   43   44