Page 33 - C++
P. 33

Ans       (i)    File.seekg(-sizeof(R), ios::cur);
                         (ii)   File.write((char*)&R,sizeof(R));

                     (½ Mark for each correct answer)
               (b)   Write  a  user-defined  function  named  Count()  that  will  read  the  contents  of  text  file   2

                     named “Report.txt”  and display the count of the number of lines that start with either

                     „I‟ or „M‟.
                     E.g. In the following paragraph, there are 3 lines starting with „I‟ or „M‟:

                     “India is the fastest growing economy.
                     India is looking for more investments around the globe.

                      The whole world is looking at India as a great market.
                     Most of the Indians can foresee the heights that India is capable of reaching.”

               Ans





















                     (½ Mark for opening opinion.txt correctly)

                     (½ Mark for fetching each line from the file correctly)
                     (½ Mark for counting each word)

                     (½ Mark for correct displaying the no. of lines which starts with „M‟ or „I‟)
               (c)   Consider the following class Item:-                                                            3






















                                                        Page No. 16
   28   29   30   31   32   33   34   35   36   37   38