Question: Program Instructions: Write a program that performs simple math expressions on command line arguments. 1 . The program should take exactly 3 arguments and check

Program Instructions: Write a program that performs simple math expressions on command line arguments.
1. The program should take exactly 3 arguments and check the number of arguments
2. Convert args 1 and 3 to numbers with atoi(). Note that atoi returns 0 for errors; you can ignore this for now.
3. Check arg 2 for valid math operations +-/ x with if or switch statements
4. Perform the correct math operation and print the results according to the sample output on the next page.
Format the printed output EXACTLY as in the sample output below (including spacing and line skips). If the number of arguments is wrong or the math symbol isnt recognized, print the word Usage and then some sensible usage instructions (however, for grading I'll only be checking that the first 5 characters are Usage ).
Note that in the samples below, the $ represents the bash prompt and is printed automatically by bash. Dont print dollar signs from your C program. The first line shows what you type, the second and third lines are the output if done correctly.
Sample of correct usage and resulting output:
$ a.out 50*-10
$ 50*-10=-500
$
Sample of incorrect usage (no spaces between arguments) which causes usage instructions to be printed
$ a.out 5+3
$ Usage ...
$

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!