Page 211 - C++
P. 211

PRACTICE PAPER -III

               Max Marks: 70                                                                          Time: 3 Hrs



   Q.1(a) What is the benefit of using default parameter/argument in a function ? Give suitable example to illustrate it using C++
                code.                                                                                        [2]
          (b)Observe the following C++ code and write the name(s) of the header file(s) , which will be essentially required to run it
               in a C++ compiler :
                 void main( )
                 {   float  Area , Side ;
                          cin>>Area ;
                          Side=sqrt(Area) ;
                          cout<<”One Side of the Square:”<<Side<<endl;
                }                                                                                            [1]
      (c) Observe the following C++ code carefully and rewrite the same after removing all the syntax error(s) present
            in the code. Ensure that you underline each correction in the code. (Note: All desired header files
            are already included, which are required to run the code. Correction should not change the logic
            of the program.)
               #define Change(A,B)  2*A+B;
               void main( )
               {
                       Float X,Y,F;
                       cin >> X>>Y;
                       F=Change[X,Y];
                       cout <<”Result:”<<F<<endline;
               }                                                                                             [2]
       (d) Observe the following C++ code carefully and obtain the output, which will appear on the screen after execution
            of it.(  Note: All desired header files are already included, which are required for it.)
               void main( )
               {
                       char *Text=”AJANTA”;
                       int *P, Num[ ]={1 , 5 , 7 , 9};
                       P=Num;
                       cout<<*P<<Text<<endl;
                       Text++;
                       P++ ;
                       cout <<*P<< Text<<endl;
               }                                                                                             [2]

      (e) Observe the following C++ code carefully and obtain the output, which will appear on the screen after execution of it.
                #include <iostream.h>
                class Mausam
                {
                       int City , Temp , Humidity;
                        public:
                       Mausam(int C=1)      {City=C;       Temp=10;      Humidity=63;}
                       void Sun(int T)      {Temp+=T;}
                       void Rain(int H)     {Humidity+=H;}
                       void CheckOut( )
                       {
                              cout<<City<<”:”<<Temp<<”&”<<Humidity<<”%”<<endl;
                       }
               };
               void main( )
               {
                       Mausam M,N(2);
                       M.Sun(5);

                                                                                                                   1
   206   207   208   209   210   211   212   213   214   215   216