Write a function main() and implement each math operations defined above. Design a basic calculator that will asks from the user to enter 2 integers and the math operator symbol as shown below: (the highlited part)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.2: Returning A Single Value
Problem 11E: (Numerical) a. The following is an extremely useful programming algorithm for rounding a real number...
icon
Related questions
Question

MULTIPLE FUNCTIONS AND RECURSIVE FUNCTIONS 

Use #include<stdio.h>

 

Write a function main() and implement each math operations defined above. Design a basic calculator that will asks from the user to enter 2 integers and the math operator symbol as shown below: (the highlited part)

 

 

Define and implement the following functions:
int sum(int x, int y)
- returns the computed sum of two integers x and
y
int diff(int x, int y)
- returns the computed difference of two nos x and y.
Make sure that the larger number is deducted
by the smaller number to avoid a negative answer
long int prod (int x, int y)
- returns the computed product of two nos x and y
float quot(int x, int y)
returns the computed quotient of two nos x and y.
Make sure that the larger number is always the numerator
and divided by the smaller number to avoid division
by zero error.
int mod(int x, int y)
- returns the computed remainder of two nos x and y using
the modulo operator %
Write a function main() and implement each math operations defined
above. Design a basic calculator that will asks from the user to enter 2
integers and the math operator symbol as shown below:
Enter first integer: 2
Enter first integer: 15
Enter second integer: 5
Enter second integer: 8
Select math operator [+-*/%]: / Select math operator [+-*/%]: %
Quotient = 2.50
Remainder = 7
At the end output the resulting value [computed value]
Transcribed Image Text:Define and implement the following functions: int sum(int x, int y) - returns the computed sum of two integers x and y int diff(int x, int y) - returns the computed difference of two nos x and y. Make sure that the larger number is deducted by the smaller number to avoid a negative answer long int prod (int x, int y) - returns the computed product of two nos x and y float quot(int x, int y) returns the computed quotient of two nos x and y. Make sure that the larger number is always the numerator and divided by the smaller number to avoid division by zero error. int mod(int x, int y) - returns the computed remainder of two nos x and y using the modulo operator % Write a function main() and implement each math operations defined above. Design a basic calculator that will asks from the user to enter 2 integers and the math operator symbol as shown below: Enter first integer: 2 Enter first integer: 15 Enter second integer: 5 Enter second integer: 8 Select math operator [+-*/%]: / Select math operator [+-*/%]: % Quotient = 2.50 Remainder = 7 At the end output the resulting value [computed value]
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr