Page 97 - Modular_V2.0_C++_Flikpbook
P. 97

4.  What is the use of the return statement in a function?

                      5.  What are global variables?
                 E.   Long answer type questions.

                      1.  What is the difference between declaring a function and defining a function? Give an example.
                      2.  What is the difference between local and global variables?
                      3.  What is the difference between formal parameters and actual arguments?

                      4.  Write a function to display your name five times.

                 F.   Find the error in the following codes:
                      1.  int div(int a, int b)                     2.  sum(int i, j)
                          {                                              {
                          a = a * b;                                     return(I / j)

                          b = b / 2;
                          }
                      3.  void disp()
                          {

                              cout>>"program";
                          }



                                                       In the lab                             21 st  Century   #Critical Thinking
                                                                                                 Skills


                     Write a program using functions to:
                         Determine whether the year is leap or not.
                         Check whether the input number is even or odd.
                         Find the sum of even numbers between 1 and 50.
                         Find the product of first 5 numbers.





                  Teacher's Corner

                 1.   Discuss different types of functions provided by C++ with the students.
                 2.   Do a walk-through of all the topics covered in this chapter.

















                                                                                                                  95
                                                                                                Functions in C++
   92   93   94   95   96   97   98   99   100   101   102