Page 232 - C++
P. 232

(d)  Write  the  definition  of  a  member  function  ADDMEM(  )  for  a  class  QUEUE  in
                         C++,  to  add  a  MEMBER  in  a  dynamically  allocated  Queue  of  Members
                         considering the following code is already written as a part of the program.      4
                         struct Member
                         {
                              int MNO;
                              char MNAME[20];
                              Member *Next;
                         };
                         Class QUEUE
                         {
                              Member *Rear,*Front;

                         public:
                              QUEUE(){Rear=NULL;Front=NULL;}
                              void ADDMEM();
                              void REMOVEMEM();
                              ~QUEUE();
                         };


                   (e)   Convert  the  following  Infix  expression  to  its  equivalent  Postfix  expression,
                         showing the stack contents for each step of conversion.                          2
                         P + ( Q – R ) * S / T

             4.    (a)   Aditi has used a text editing software to type some text. After saving the article as
                         WORDS.TXT,  she  realised  that  she  has  wrongly  typed  alphabet  J  in  place  of
                         alphabet I everywhere in the article.                                            3

                         Write  a  function  definition  for  JTOI()in  C++  that  would  display  the  corrected
                         version of entire content of the file WORDS.TXT with all the alphabets “J” to be
                         displayed as an alphabet “I” on screen.
                         Note : Assuming that WORD.TXT does not contain any J alphabet otherwise.
                         Example :
                         If Aditi has stored the following content in the file WORDS.TXT :


                          WELL, THJS JS A WORD BY JTSELF. YOU COULD STRETCH
                          THJS TO BE A SENTENCE

                         The function JTOI( ) should display the following content :

                          WELL, THIS IS A WORD BY ITSELF. YOU COULD STRETCH
                          THIS TO BE A SENTENCE


             91/1                                          7                                        [P.T.O.
   227   228   229   230   231   232   233   234   235   236   237