Page 280 - C++
P. 280

4.   (a)     Polina Raj has used a text editing software to type some text in an
                   article. After saving the article as MYNOTES.TXT, she realised that
                   she has wrongly typed alphabet K in place of alphabet C everywhere
                   in the article.
                   Write  a  function  definition  for  PURETEXT()  in  C++  that  would
                   display  the  corrected  version  of  the  entire  article  of  the  file
                   MYNOTES.TXT  with  all  the  alphabets  ――K‖‖  to  be  displayed  as  an
                   alphabet ――C‖‖ on screen.                                                       3
                   Note : Assuming that MYNOTES.TXT does not contain any C alphabet
                   otherwise.
                   Example :
                   If Polina has stored the following content in the file MYNOTES.TXT :


                    I OWN A KUTE LITTLE KAR.
                    I KARE FOR IT AS MY KHILD.

                   The function PURETEXT() should display the following content :

                    I OWN A CUTE LITTLE CAR.
                    I CARE FOR IT AS MY CHILD.


           (b)     Write a definition for function COUNTPICS( ) in C++ to read each
                   object  of  a  binary  file  PHOTOS.DAT,  find  and  display  the  total
                   number  of  PHOTOS  of  type  PORTRAIT.  Assume  that  the  file
                   PHOTOS.DAT is created with the help of objects of class PHOTOS,
                   which is defined below :                                                        2

                   class PHOTOS
                   {
                       int PCODE;
                       char PTYPE[20];//Photo Type as “PORTRAIT”,“NATURE”
                   public:
                       void ENTER()
                       {
                         cin>>PCODE;gets(PTYPE);
                       }


                       void SHOWCASE()
                       {
                         cout<<PCODE<<":" <<PTYPE<<endl;
                       }
                       char *GETPTYPE(){return PTYPE;}
                   };
      91                                            10
   275   276   277   278   279   280   281   282   283   284   285