Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

PLease IN C not in C++ or JAVA, Lab3. Write a computer program in C which will simulate a calculator. Your calculator needs to support

PLease IN C not in C++ or JAVA,

Lab3. Write a computer program in C which will simulate a calculator. Your calculator needs to support the five basic operations (addition, subtraction, multiplication, division and modulus) plus primality testing (natural number is prime if it has no non-trivial divisors).

: Rewrite your lab 3 calculator program using functions. Each mathematical operation in the menu should be represented by a separate function. In addition to all operations your calculator had to support in lab 3, please add additional functionality to your calculator. Include the ability to compute the factorial of an integer (Example: 4! = 1 * 2 * 3 *4 = 24), and an integer power of a number (Example: 53 = 5 * 5 * 5 = 125). Finally, add an interesting mathematical function of your choosing which computes the first n numbers of a sequence of numbers and utilizes an array to store the result before displaying it (Examples of mathematical sequences: Fibonacci, Primes). Example of the output follows:

Calculator Menu:

(1) Addition

(2) Subtraction

(3) Multiplication

(4) Division

(5) Modulus (integers only)

(6) Test if prime (integers only)

(7) Factorial (integers only)

(8) Power

(9) Your function

(0) Exit

Please choose an operation: 8

Enter the first number: 5

Enter the second number: 3

5^3 = 125

Calculator Menu:

(1) Addition

(2) Subtraction

(3) Multiplication

(4) Division

(5) Modulus (integers only)

(6) Test if prime (integers only)

(7) Factorial (integers only)

(8) Power

(9) Your function

(0) Exit Please choose an operation: 0

Good Bye!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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