Question: < C programming> This assignment focuses on creating andmanipulating selection control structures. The user will enter an expression (arithmetic, logical, or relational) and you will

< C programming>

This assignment focuses on creating andmanipulating selection control structures. The user will enter an expression (arithmetic, logical, or relational) and you will display the result of the expression.

Instructions

Create a program called selection.c that does the following:

Prompt for and accept an expression of the form: (axb)y(czd) ( stands for space) where a, b, c, and d are integer values; x, y, z are single characters representing operators; and the parentheses and spaces are entered as shown

There are three categories of operators that may be entered for the x, y, and z values:

Arithmetic operators: +, -, *, /, and %

Single-character relational operators: < and >

Single-character versions of the C logical operators:

& for && (logical AND)

| for || (logical OR)

! for logical NOT

Verify that all operators (the x, y, and z values) are of the same category. If the user enters operators of different categories issues an appropriate error message and end the program

Evaluate the expression and display the result

If the user entered arithmetic operators the result should be an integer value

If the user entered a relational or logical expression the result should be displayed as the string true or the string false

Your program must adhere to the class coding standards, and will be graded using the assignment grading criteria. Submit your source code file to the Desire2Learn dropbox for this assignment.

Sample Output (Several executions of the program)

Program: Selection Author: Doug Jones Enter an expression: (2 + 4) * (3 - 4) Result: (2 + 4) * (3 - 4) = -6 Program: Selection Author: Doug Jones Enter an expression: (2 > 4) * (3 < 4) Result: (2 > 4) * (3 < 4) is not a valid expression for this program

Program: Selection Author: Doug Jones Enter an expression: (4 < 4) > (3 > 3) Result: (4 < 4) > (3 > 3) = false Program: Selection Author: Doug Jones Enter an expression: (0 & 1) | (1 & 1) Result: (0 & 1) | (1 & 1) = true

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve the assignment task you will need to write a C program that reads an expression from the user checks the validity of operators evaluates the ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!