Question: Make a calculator in C in which if the user enters add 3 5, it calculates 3 + 5. If the user enters multiple 3

Make a calculator in C in which if the user enters add 3 5, it calculates 3 + 5. If the user enters multiple 3 5, it multiplies 3 by 5. Same for subtraction and division. If the user enters collatz n, it would check whether n is even and if it is, divide it by two, otherwise multiple n by 3 and add 1. This is done until n reaches 0. Return the collatz sequence. Exit when the user enters "bye".

The following input should give an error:

add 3 7 8

3 8 add

add 9 b

8 add 9

col 9 b

col b 9

Anything other than "add", "divide", "multiply", etc, followed by two integers and "collatz" followed by one integer should give an error. If "bye" is entered following by anything else it should give an error as well.

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 Databases Questions!