Page 160 - C++
P. 160

{

               TEXTBOOKS *Top;

               public:

               STACK(){Top=NULL;}

               void Push();

               void Pop();

               ∼STACK();

        };



         (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


                                                             OR
        (e ) Evaluate the following postfix expression. Show status of the stack after execution of each operation
        separately:                                                                                          (2)


        F, T, NOT, AND, F, OR, T, AND


        Q4 (a) Write a function to count the number of words present in a text file named“PARA.TXT”. Assume that
        each word is separated by a single blank/space character and no blanks/spaces in the beginning and end of
        the file.                                                                                             (2)

                                                             OR


        (a) Write a function in C++ to count and display the number of lines starting with alphabet ‘A’ present in a text
            file “PLAY.TXT”.                                                                                  (2)


        Example : If the file “PLAY.TXT” contains the following lines

        A boy is playing there. There is a playground.
        An airplane is in the sky. Alphabets and numbers are allowed in the password.

        The function should display the output as 3


         (b) Write a function in C++ to search and display details, whose destination is “Delhi” from binary file
        “Train.Dat”. Assuming the binary file is containing the objects of the following class:              (3)

        class TRAIN

        {

                       int Tno; // Train Number
   155   156   157   158   159   160   161   162   163   164   165