Page 79 - C++
P. 79
OR
( 1 Mark for creating new node Book)
(1 Mark for assigning top to temp)
(1 Mark for top=top->next)
(1 Mark for delete top)
(e) Convert the following Infix expression to its equivalent Postfix expression, (2)
showing the stack contents for each step of conversion.
A/B+C*(D-E)
OR
Evaluate the following Postfix expression :
4,10,5,+,*,15,3,/,-
Ans:
Element Stack Postfix
A A
/ / A
B / AB
+ + AB/
C + AB/C
* +* AB/C
( +*( AB/C
D +*( AB/CD
- +*(- AB/CD
E +*(- AB/CDE
) +* AB/CDE-
+ AB/CDE-*
AB/CDE-*+
OR
55
(½ Mark for conversion upto each operator illustrating through stack)
OR
(1/2 Mark for evaluating each operator)
4 (a) Write a function RevText() to read a text file “ Input.txt “ and Print only (2)
word starting with ‘I’ in reverse order .
Example: If value in text file is: INDIA IS MY COUNTRY
Output will be: AIDNI SI MY COUNTRY
OR
Write a function in C++ to count the number of lowercase alphabets
present in a text file “BOOK..txt".
15