Page 243 - C++
P. 243

CBSE AISSCE 2016-2017 Marking Scheme for Computer Science
                                         (Sub Code: 083 Paper Code 91/1 Delhi)

                   Ans     iostream.h or iomanip.h or fstream.h
                           string.h
                           stdio.h

                           (½ Mark each for writing any two correct header files)

                           NOTE:
                           Ignore additional header file(s)

                   (c)     Rewrite the following C++ code after removing any/all syntactical errors                             2
                           with each correction underlined.
                           Note: Assume all required header files are already being included in the
                           program.
                           void main()
                           {
                             cout<<"Enter an integer";
                             cin>>N;
                             switch(N%2)
                                  case 0 cout<<"Even"; Break;
                                  case 1 cout<<"Odd" ; Break;
                           }

                   Ans     void main()
                           {
                             ​int N; ​                          // Error 1

                             cout<<"Enter an integer";
                             cin>>N;
                             switch(N%2)
                             ​{ ​                              // Error 2 (i)
                                  case 0​:​                      // Error 3 (i)
                                       cout<<"Even"; ​break;​  // Error 4 (i)

                                  case 1​:​                      // Error 3 (ii)
                                       cout<<"Odd" ; ​break;​  // Error 4 (ii)
                              } ​                                                                       ​// Error 2 (ii)
                          }

                           (½ Mark for correcting Error 1)
                           (½ Mark for correcting Error 2(i) and Error 2(ii))
                           (½ Mark for correcting Error 3(i) and Error 3(ii))
                           (½ Mark for correcting Error 4(i) and Error 4(ii))

                           OR
                           (1 Mark for identifying all the errors without corrections)

                   (d)    Find and write the output of the following C++ program code:                        2
                          Note: Assume all required header files are already included in the

                          program.
                            #define Big(A,B) (A>B)?A+1:B+2
                            void main()



                                                     Page #2 of 28
   238   239   240   241   242   243   244   245   246   247   248