Page 31 - C++
P. 31

Ans












                     (1 Mark for correct loop)
                     (1 Mark for correct placing elements)

               (e)   Evaluate the following POSTFIX expression. Show the status of Stack after execution of         2

                     each operation separately:
                                   TRUE, FALSE, OR, NOT, TRUE, FALSE, AND, OR

               Ans       S. No.              Element Scanned     Operation           Stack Status

                         1                   True                Push  (True)        True
                         2                   False               Push  (False)       True, False

                         3                   OR                  Pop(False)          True
                                                                 Pop(True)

                                                                 OR(True,
                                                                 False)=True

                                                                 Push (True)

                         4                   NOT                 Pop(True)           False
                                                                 NOT(True)=False



                         5                   True                Push  (True)        False, True
                         6                   False               Push  (False)       False,  True, False

                         7                   AND                 Pop(False)          False, False

                                                                 Pop(True)
                                                                 AND(False,

                                                                 True)=False
                                                                 Push False

                         8                   OR                  Pop(False)          False
                                                                 Pop(False)

                                                                 OR(False,

                                                                 False)=False



                                                        Page No. 14
   26   27   28   29   30   31   32   33   34   35   36