question1

Write a program to process commands as follows.A command can be S(for set) or P(for print),upper or lower case.Each command is on a line by itself ,but can apperar any where on the line.

The S command is followed by two arguments separated by one or more spaces.The first argument is a sssingle letter(upper or lower caese).The scond argument is an arithmetic expression.The command assigns the value of the expression to a single letter variable.Variables are Case-sensitive.(A is different from a).

An expression may include single letter variables ,numeric constants,(with or without decimal point),the binary operators +,-,/,* and the function names ln,exp,sqrt,sin, and cos.If a variable appears in the expression ,then the current value of the variable is used in evaluating the expression.If the expression contains an error (eg mismatched brackets or undefines brackets),a message is printed and the value of the variable to be set reamins unchanged.

the P command is folllowed by a varable,.The value of the variable is printed.

data consists of a series of commands in any order.The commands must be executed in the order given.Data is terminated by the"command",E.It is permitted for the S caomand to be specified by S,s,set,Set,setting variable,etc.(only the first letter is significant);similarly for P

sample data:

S p 24

set r 3.75

s a P+r*21

Set B sin(p+r)*cos(p-r)+p/(r+3.0)

print B

P p

P a

S C (a+B)/(p+r)

set discr B*B -4.0 a*C

PRINT discr

E