Page 344 - C++
P. 344

CBSE AISSCE 2017-2018 Marking Scheme for Computer Science
                                       (2018-2019 Sub Code: 083       Paper Code: 91)

                    Ans    (i) fstream      (ii) string


                           (½ Mark for writing each correct answer)
                           NOTE: Any other header file to be ignored

                     (c)   Rewrite the following C++ code after removing any/all syntactical errors with                                 2
                           each correction underlined.
                           Note​: Assume all required header files are already included in the program.
                           Typedef Count int;
                           void main()
                           {

                             Count C;
                             cout<<"Enter the count:";
                             cin>>C;
                             for (K = 1; K<=C; K++)
                               cout<< C "*" K <<endl;
                           }


                    Ans  typedef​ ​int Count​;              //Error 1, Error 2
                           void main()
                           {
                             Count C;
                             ​int K;​   //OR ​Count K;​              //Error 3

                             cout<<"Enter the count:";
                             cin>>C;
                             for (K = 1; K<=C; K++)
                             //​OR​ for (​int​ K = 1; K<=C; K++)    //Error 3

                             //​OR ​for (​Count​ K = 1; K<=C; K++)  //Error 3
                              cout<< C ​<< ​"*" ​<< ​K <<endl;      //Error 4
                              //​OR​ cout<<​C * K​<<endl;           //Error 4

                           }

                           (½ Mark for correcting each correct Error)
                           NOTE:
                           (1 Mark for only identifying all the errors correctly)


                    (d)    Find and write the output of the following C++ program code:                        3
                           Note​: Assume all required header files are already included in the program.
                           void Revert(int &Num, int Last=2)
                           {
                             Last=(Last%2==0)?Last+1:Last-1;
                             for(int C=1; C<=Last; C++)
                               Num+=C;
                           }

                                                        Page #2/35
   339   340   341   342   343   344   345   346   347   348   349