Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

User enters an equation with the following requirements:

I need help writing a c code. User enters an equation with the following requirements:

a. Valid variable names may have at most 6 characters (Allowed characters are lower/upper case English alphabets, underscore). Space, numbers, and special characters are not allowed in variable names.

b. Parenthesis is not allowed in the expression.

c. +, -, / and * are the four allowed operators. All operators need two operands. Unary operators are not allowed.

d. Spaces are allowed between variables, operators. At most 3 spaces may be allowed.

e. Expression is evaluated from left to right.

Develop C code for parsing a mathematical expression as specified by above rules and determine if it is a valid expression.

Print a message "expression is valid" or "expression is invalid".

The mathematical expression may be at most 100 characters long.

There may be at most 10 variables in the expression.

If the expression is invalid, print one of the following diagnostic message when appropriate - "invalid variable" followed by partial name of the variable which is invalid, "excessive space" for more than 3 spaces.

If the expression is valid, print the output showing details of variables and operators as shown in the example above.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question