Page 139 - C++
P. 139

MODEL TEST PAPER V




              Time: 3 Hrs.                                                                 Max. Marks: 70



              1. (a)  What are the two factors on which access of the inherited members depend?         [2]
                (b)  Name the header files that shall be needed for successful compilation of the following C++
                   code:                                                                                [1]
                   void main()
                    {
                    charstr[20],
                    str[20];
                    gets(str);
                    strcpy(str1,str);
                    strrev(str);
                    puts(str);
                    puts(str1);
                    }
                (c)  Anita has just started working as a programmer in STAR SOFTWARE Company. In the company she
                   has got her first assignment to be done using a C++ function to find the smallest number out of
                   a given set of numbers stored in a one-dimensional array. But she has committed some logical
                   mistakes while writing the code and is not getting the desired result. Rewrite the correct code
                   underlining the corrections done. Do not add any additional statements in the corrected code.
                                                                                                        [2]
                   int find(int a[ ],int n)
                    {
                    int s=a[0];
                    for(int x=1;x<n;x++)
                    if(a[x]>s)
                    a[x]=s;
                    return(s); }
                (d)  Find the output of the following program:                                          [3]
                   #include <iostream.h>
                    struct Game
                    {
                    char Magic[20];
                    int Score;
                    };
                    void main()
                    {
                    Game M={“Tiger”,500};
                    char *Choice;
                    Choice=M.Magic;
                    Choice[4]=’P’;
                    Choice[2]=’L’;
   134   135   136   137   138   139   140   141   142   143   144