Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, can someone help me with this one? We are just starting to learn C so we did not see any special commande, just basic

Hi, can someone help me with this one? We are just starting to learn C so we did not see any special commande, just basic one. I am using Linux. Thanks!
image text in transcribed
image text in transcribed
Total Points: 20 Ex. 1 - A Simple Interger Calculator (9 Points) In this exercise, you will create a C program to implement a simple integer calculator Your calculator should accept three arguments as input, x, op, y, where x and y are integers and op is one of the operators +, -, *, / to perform the corresponding arithmetic operations. 1. Use vi to create a C program source file simplecalc.c 2.(1 Point) The program should include a comment section at the beginning that describes its purpose (couple of lines), the author your name), your department, a small "history section indicating what changes you did on what date. Program to implement a simple calculator Author Dept. Date Notes * ** * * ******************************************** Joseph D Joseph D Comp. Science. Feb 10 2020 Comp. Science. Feb 11 2020 Initial version. Added error handling. The code should be properly indented for readability as well as contain any additional comments required to understand the program logic. 3. (1 Point) The source code should be compilable by (exactly) using the command gee -o simplecalc simplecalc.c 4.(3 Points) Your program should accept the three arguments mentioned above as its input. If the user does not pass this argument, you should display an error message and terminate with error code 1. $ ./simplecalc Error: usage is simplecalc $ echo $? 5.(4 Points) Your program performs simple arithmetic operations on the input as indicated by the operator and displays the output. You should use a switch statement to decide which operator to execute. You will loose 2 points if you do not use the switch. If the user enters one of the operators not listed above, print an error message and terminate with error code 2. Successfull execution of the program should result in a return code of O from the program $ ./simplecalc 5 + 3 $ echo $? $ ./simplecalc 5 - 3 $ /simplecalc 5 + 3 $ ./simplecalc 5 / 3 $ ./simplecalc 5 0 3 not a valid operator $ echo $

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions