Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

calculator: Write a program that takes three command-line arguments: number operator number and performs the required operation and prints the result on a single complete

calculator: Write a program that takes three command-line arguments: number operator number and performs the required operation and prints the result on a single complete line in standard output. (The four operators of a arithmetic, + * - /, must be recognized here.

This is the code I have:

#include using namespace std; int main(int argc, char * argv[]) {total; if (strcmp(argv[2], "+") == 0) tot=atoi(argv[1])+atoi(argv[3]); else if (strcmp(argv[2], "-") == 0) tot=atoi(argv[1])-atoi(argv[3]); else if (strcmp(argv[2], "/")== 0) tot=atoi(argv[1])/atoi(argv[3]); else if(strcmp(argv[2], "*") == 0) tot=atoi(argv[1])*atoi(argv[3]); else {cout<<"illegal input "; return 1; } cout<

and I keep getting the error message 'you might be using the wrong number somewhere in your solution but I can't figure out where.

Thanks in advance for help

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_2

Step: 3

blur-text-image_3

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

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions