Page 204 - C++
P. 204

PRACTICE PAPER -II
                   Max Marks: 70                                                           Time: 3 Hrs

                   Q1)
                   a)  Differentiate between ordinary function and member functions in C++. Explain
                       with an example.                                                                 (2)
                   b)  Write the related library function name based upon the given information in
                       C++. (1)
                         i) Terminate the program. This function is available in process.h file.
                        ii) To join a string at the end of another string. This function is available in
                   string.h file.
                   c) Rewrite the following program after removing the syntactical errors (if any).
                   Underline
                       each correction. (Assuming all desired header file(s) are already included)        (2)
                       typedef char[50] STRING;
                       Void main( )
                         {
                          city STRING
                          gets(city);
                          cout << city[0] << ‘::’ << city[2];
                          cout << city << endl;
                          }
                   d) Find the output of the following program:
                   (2)
                       # include <iostream.h>
                       struct score
                       {
                         int year;
                         float topper;
                       };
                       void change(score * s, int x = 20)
                       {
                         s−>topper = (s−>topper + 25) – x;
                         s−>year++;
                       }
                       void main()
                       {
                         Score arr[ ] = {{2007, 100}, {2008,95}};
                         score * point = arr;
                         change (point, 50);
                         cout << arr[0].year << ’#’ << arr[0].topper << endl;
                         change(++point);
                         cout << point−>year << ’#’ << point−>topper << endl;
                       }
                   e ) Study the following program and select the possible output(s) from the option (i)
                   to
                       (iv) following. Also write the maximum and minimum values that can be assigned
                   to
                       the variable value.                                                               (2)
                         # include <iostream.h>
                         # include <stdlib.h>
                         void main( )
                         {
                            randomize( );
                            int value;
                            value = random(2) + 2;
                            char yourself[ ] = {“ONE”, “TWO”, “SIX”, “TEN”};
                               for (int y = 0; y < value; y++)
                                    cout << yourself[y];
                               cout << “END” << endl;
                             }
                      i)     ONETWOEND
   199   200   201   202   203   204   205   206   207   208   209