Lab6 Assignment
Lab6 Assignment
Problem Statement
No
Write Lex and Yacc program for the following : ( Question 1 - 5 marks, Question 2 - 5 marks )
John is a newbie programmer. He has a string which is an arithmetic expression, he is struggling to find the
1 result of this string by creating a YACC program. He also wants to know whether arithmetic expression is valid
or not. John needs your help to write the YACC program.
Input format
Output format
(( 7 * 2 - 12 * 1 + 2) / 7) % 3 (2 * 4) + (4 / 5) + 5 - 2 - 1 * 7 %
Valid Invalid
? ?
2 Zayan is throwing a birthday party. Seeing the extravagant parties thrown by her friends like Varaa and Arik in
the past, Zayan too decided to do something unique. Being a Computer Engineer himself, he knew just how to
do it. He sent a password-protected e-invites(string) to his friends. Now their task is to convert the given string
which is an infix expression to a postfix expression and to find the result of that string. Underscore separated
postfix expression and result which would be the password for that invite. Help Zayan friends in finding the
Input format
Output format
Constraints
8 15 5 3 * / - 10 + 7 2 % 12 12 / 8 * - 3 + 20 % ?
17 ? ?
81553*/-10+_17 ? ?