Page 61 - DCAP404 _Object Oriented Programming
P. 61

Object-oriented Programming




                    Notes          Keywords: Explicitly reserved identifiers that cannot be used as names for the program variables
                                   or other user defined program elements.
                                   Operands: The data items that operators acted upon all called operands.

                                   Scope Resolution Operator: This operator enables a program to access a global variable when a
                                   local variable of the same name is in scope.
                                   String Constant: Sequence of characters enclosed in double quotes.

                                   Tokens: A collections of characters, much live a word in English language. The smallest individual
                                   unit in a program.

                                   2.9 Review Questions


                                   1.  Are ‘break‘ and ‘continue‘ bad programming practices? Analyze.
                                   2.  Does the last element in a loop deserve a separate treatment? Why or why not?
                                   3.  Which useful alternative control structures do you know? Explain with an example.
                                   4.  Does C++ provide any trinary operator? If yes, explain its working.
                                   5.  Convert the following while loop into for loop.

                                       int  i  =  10;
                                       while(i  <  20)
                                       {

                                            cout  <<  i;
                                            (i++)++;
                                       }
                                   6.  In control structure switch-case what is the purpose of default in C++?
                                   7.  Write a C++ program to display and add five numbers.

                                   8.  What is the difference between dynamic and reference declaration of variables?
                                   9.  What are operators? What are their functions? Give examples of some unary and binary
                                       operators.

                                   10.  What are keywords? Can keywords be used as identifiers?

                                   Answers: Self  Assessment

                                   1.  Boldface                          2.   Name
                                   3.  Identifier                        4.   Operands
                                   5.  Variable                          6.   Numeric

                                   7.  Double                            8.   Bit
                                   9.  If-else statement                 10.  While
                                   11.  Break                            12.  Current
                                   13.  Block                            14.  Pointer

                                   15.  Variable



          54                                LOVELY PROFESSIONAL UNIVERSITY
   56   57   58   59   60   61   62   63   64   65   66