Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this project, we will work to familiarize ourselves with the tools used in this course and practice their use with a simple example. You

In this project, we will work to familiarize ourselves with the tools used in this course and practice their use with a simple example. You will write a program in C called math.c that uses a combination of command line arguments, standard input and standard output to perform basic calculations with +,-,* and /.
(Only implement integer division for this project [3/2==1], this is the default behavior of "/" on integers in C).
Program Behavior
Program takes between 1 and 3 arguments
Argument 1 is the operation (one of +-* or /)
Arguments 2 and 3 are optional (see below) and are the numeric operands
If less than 3 arguments are provided, use scanf to query the operands from the user
DO NOT prompt the user (there should only be one printf in your program)
Program calls printf to return the numeric result of the operation
ONLY the numeric result should be printed (no extra characters)
Program's return code MUST match the printed value
Testing
As described in Appendix B, you MUST compile your programs using the -O0-Wall -Werror -pedantic -std=c11 gcc options when testing.
gcc -O0-Wall -Werror -pedantic -std=c11-o math math.c
Examples
Addition all command line
Command
./math +100101
Output
201
Multiplication all command line
Command
./math *2202
Output
404
Subtraction one command line
Command
./math -12
Input
10
Output
2
Division no command lines
Command
./math /
Input
8
2
Output
4

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions