Page 66 - C++
P. 66

#define PI 3.14//Error 1
                             void main( )
                             {
                                    float  R=4.5,H=1.5;
                                    floatA=2*PI*R*H + 2*PI*pow(R,2);            //Error 2, 3
                                    cout<<“Area=”<<A<<endl;                            //Error 4
                             }

                             (½ Mark for each correction)
                             OR
                             (1 mark for identifying the errors, without suggesting corrections)

                      (d)    Find and write the output of the following C++ program code:                  (3)
                             Note:  Assume all required header files are already being included in
                             the program.
                             void main( )
                             {
                                    int Ar[ ] = { 6 , 3 , 8 , 10 , 4 , 6 , 7} ;
                                    int *Ptr = Ar , I ;
                             cout<<++*Ptr++ << '@' ;
                             I = Ar[3] - Ar[2] ;
                             cout<<++*(Ptr+I)<<'@'<<"\n" ;
                             cout<<++I + *Ptr++ << '@' ;
                             cout<<*Ptr++ <<'@'<< '\n' ;
                             for( ; I >=0 ; I -=2)
                                    cout<<Ar[I] << '@' ;
                             }

                      Ans    7@11@
                             6@8@
                             11@3@

                             (½ Mark for writing each correct value)
                             OR
                             (Only ½ Mark for writing all ‘@’  at proper places)
                             Note:
                             ● Deduct only ½ Mark for not considering any or all correct placements of
                                @
                             ● Deduct only ½ Mark for not considering any or all line break

                      (e)    Find and write the output of the following C++ program code:                  (2)
                             typedef char STRING[80];
                             void MIXNOW(STRING S)
                             {
                                 int Size=strlen(S);
                                 for(int I=0;I<Size;I+=2)
                                 {
                                           char WS=S[I];



                                                              2
   61   62   63   64   65   66   67   68   69   70   71