You are on page 1of 6

QUESTION: 01

Using Stack check the brackets entered by a user are balanced i.e. they match in number
and sequence.
You can take input just the string of brackets e.g. [ { ( ) } ] there are 3 types of brackets [ ] ,
{ }, and ( ) that can be used in expressions.
The output of the program should tell the user whether the brackets string is OK or there
is some mismatch in brackets.
OUTPUT:

QUESTION: 02
Convert the following infix expression into postfix expression using Stack and then
evaluate it,
a.        ( a + b ) – ( c / ( d + e ) )
b.        a / ( ( b / c ) * ( d – e ) )
c.        ( a / ( b / c ) ) * ( d – e )
Use a = 5, b = 10, c= 2, d= 4 and e = 1 when evaluating expressions.

1. (a + b ) – ( c / ( d + e ) )
= ( 5 + 10 ) – ( 2 / ( 4 + 1 ) )
1. (a / ( ( b / c ) * ( d – e ) )
= ( 5 / ( ( 10/ 2 ) * (4 – 1 ) )
2. ( a / ( b / c ) ) * ( d – e )
= ( 5/ (10 /2 ) )* (4 – 1 )

You might also like