Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C language: Create a calculator program with the following functions below the definition for main() in alphabetical order by function name: A function to

In C language: Create a calculator program with the following functions below the definition for main() in alphabetical order by function name:

  • A function to display the menu and return the user's input concerning one of the menu options(add, subtract, divide, multiply, determine the largest number, average, determine each number in the array is positive, negative, or zero,
  • A function to get several numbers, which: Receives the memory address of a fixed array, allowing for several numbers, and its size; the size of the array will be initially determined by you at the top of main(); start with at least a size of three, and then, while thoroughly testing your program change it to a larger size, Ask the user for each number, which can be any number, so make sure you use an appropriate data type until the array is full
  • A function to process the user's menu selection, which: Calls other functions as needed to get input, do calculations, determine other things, and display output, Displays an error message if the user tries to select one of the mathematical type options before getting the numbers, Displays an error message for any invalid choices, Display any other error messages as needed, Displays a good-bye message when exiting
  • A function to add up the numbers of a fixed array and return the sum to the calling function, NOT display it to the screen
  • A function to subtract the second, third, etc. numbers from the first number of a fixed array and return the difference to the calling function, NOT display it to the screen.
  • A function to multiply the numbers of a fixed array and return the product to the calling function, NOT display it to the screen.
  • A function to determine if the array can be divided without error, i.e., there are no zeros in the second, third, etc. positions in the array.
  • A function to divide the first number by the second, their quotient by the third number, etc. from a fixed array and returns the quotient to the calling function, NOT display it to the screen. Validates the array concerning the cannot divide by zero issue up to the calling function.
  • A function to calculate the average based on the numbers in a fixed array and return it back to the calling function, NOT display it to the screen.
  • A function to determine only the largest number in a fixed array and return it back to the calling function, NOT display it to the screen.
  • A function to determine whether each number in a fixed array is positive, negative, or zero, and displays the result of each number to the screen; alternatively, you could have the function return a code or set of codes, e.g., -1 for negative, 0 for zero, and 1 for positive, and let the calling function use the code to display the results for each number in the array.
  • A function to display to the screen the numbers in the array, one of the mathematical operates from the menu, i.e., add, subtract, multiply, divide, or average, and the related result.
  • Constants and variables should either be passed into or declared at the top of the functions as needed, NOT throughout the functions
  • There should only be one return statement at the end of nonvoid functions; just like you should NOT use break or continue to get out of a loop
  • Do NOT use any other code or function calls to prematurely exit a function; see the return comment above
  • The functions should be self-contained, i.e., each function should only rely on what gets passed into the function through the parameter list.
  • Define all necessary constants or variables for main() at the top of main(); except concerning the constant you need to define above main() for the size of the array
  • Use a do-while loop, which ends when exit/quit is selected from the menu; the only other loops you should need are the for loops in the functions for processing the array
  • Inside the do-while loop, there should only be assignments to variables as needed and function calls.

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

U.S. Mergers And Acquisitions Legal And Financial Aspects

Authors: Felix Lessambo

1st Edition

3030857344,3030857352

More Books

Students also viewed these Finance questions

Question

What are the main principles involved in strategic change?

Answered: 1 week ago