Page 16 - 6437
P. 16

// function declaration

                            int func();


                            int main()
                            {

                                 // function call
                                 int i = func();

                            }


                            // function definition
                            int func()

                            {
                                 return 0;

                            }


                          Lvalues and Rvalues in C
                          There are two kinds of expressions in C:
                                       lvalue  :  Expressions  that  refer  to  a  memory  location  are  called  "lvalue"
                   expressions. An lvalue may appear as either the left-hand or right-hand side of an assignment.
                                       rvalue  :  The  term  rvalue  refers  to  a  data  value  that  is  stored  at  some
                   address  in  memory.  An  rvalue  is  an  expression  that  cannot  have  a  value  assigned  to  it  which
                   means an rvalue may appear on the right-hand side but not on the left-hand side of an assignment.
                          Variables  are  lvalues  and  so  they  may  appear  on  the  left-hand  side  of  an  assignment.
                   Numeric literals are rvalues and so they may not be assigned and cannot appear on the left-hand
                   side. Take a look at the following valid and invalid statements:




                 int g = 20;         // valid statement
                 10 = 20;            // invalid statement; would generate compile-time error























                                                                                                      18
   11   12   13   14   15   16   17   18   19   20   21