
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
![User defined Function: Void Function
3. Create a program that will add, subtract, multiply and divide two numbers.
• Use user defined function for each operator
• Any number divided by zero will result to undefined
• Use int data type only for all variables declared
Example Program Output:
MENU
MENU
MENU
(A) - addition
subtraction
[M] - mulțiplication
division
(X) - exit
addition
subtraction
mulțiplication
division
exit
addition
subtraction
multiplication
division
exit
(A)
(M)
[D)
IXI
[M)
[D]
IX)
Enter your choice: a
Enter your choice: s
Enter your choice:
ADDITION
Enter first number: 10
Enter second number: 20
The sum is 30
SUBTRACȚION
Enter first number: 101
MULTIPLICATION
Enter first number: 13
Enter second number: 3
The product is 39
Enter second number: 90
The difference is 11
MENU
MENU
MENU
(A)
addition
IS)
(A) - addition
addition
subtraction
[M) - multiplication
ID) division
IXI - exit
(A)
[M)
[D]
subtraction
multiplication
division
IX)
IN)
(DI
(X) - exit
subtraction
nultiplication
division
exit
Enter your choice: d
Enter your choice: d
Enter your choice: x
Thank you!
DIVISION
Enter first number: 10
Enter second number: 0
Undefined!
Press any key to continue
DIVISION
Enter first number: 18
Enter second number: 3
The qoutient is 6](https://content.bartleby.com/qna-images/question/16decee3-19c2-46ba-9f4f-d13712fbb5fb/71700579-ecf4-408b-b61a-648d90cceb12/e7e165m_thumbnail.jpeg)
Transcribed Image Text:User defined Function: Void Function
3. Create a program that will add, subtract, multiply and divide two numbers.
• Use user defined function for each operator
• Any number divided by zero will result to undefined
• Use int data type only for all variables declared
Example Program Output:
MENU
MENU
MENU
(A) - addition
subtraction
[M] - mulțiplication
division
(X) - exit
addition
subtraction
mulțiplication
division
exit
addition
subtraction
multiplication
division
exit
(A)
(M)
[D)
IXI
[M)
[D]
IX)
Enter your choice: a
Enter your choice: s
Enter your choice:
ADDITION
Enter first number: 10
Enter second number: 20
The sum is 30
SUBTRACȚION
Enter first number: 101
MULTIPLICATION
Enter first number: 13
Enter second number: 3
The product is 39
Enter second number: 90
The difference is 11
MENU
MENU
MENU
(A)
addition
IS)
(A) - addition
addition
subtraction
[M) - multiplication
ID) division
IXI - exit
(A)
[M)
[D]
subtraction
multiplication
division
IX)
IN)
(DI
(X) - exit
subtraction
nultiplication
division
exit
Enter your choice: d
Enter your choice: d
Enter your choice: x
Thank you!
DIVISION
Enter first number: 10
Enter second number: 0
Undefined!
Press any key to continue
DIVISION
Enter first number: 18
Enter second number: 3
The qoutient is 6
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 4 images

Knowledge Booster
Similar questions
- **C PROGRAMMING LANGUAGE **PLEASE PUT SOME COMMENTS ** DOUBLE CHECK IF IT WORKS Q IN PICTUREarrow_forwardFunction Name: compliments Parameters: answer1 - a boolean (True or False) representing whether the user is "smart" answer2 - a boolean (True or False) representing whether the user is "awesome" answer3 - a boolean (True or False) representing whether the user is "fun" Description: Write a function that outputs a string of compliments based on the adjectives selected by the inputs. Use the inputs True and False. The function should return the string “You are” concatenated with the compliments that are true. The three compliments should be: "smart" "awesome" and "fun". If none of the compliments are true, print the string “Goodbye.” instead. Test Cases: >>>compliments(True, True, True) You are smart awesome fun. >>>compliments(False, True, False) You are awesome. >>>compliments(False, False, False) Goodbye.arrow_forwardParameters are the value passed to a function when the function is called and Argument are the variable defined in the function definition. True or falsearrow_forward
- Driving costs - functions Learning Objectives Create a function to match the specifications Use floating-point value division Instructions Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print(f'{your_value:.2f}') Ex: If the input to your program is: 20.0 3.1599 the output is: The gas cost for 10 miles is $1.58 The gas cost for 50 miles is $7.90 The gas cost for 400 miles is $63.20 Your program must define and call the driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles. Ex: If the function is called with: 50 20.0 3.1599 the function returns: 7.89975 def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon) Your program should…arrow_forwardCustomized step counter Learning Objectives In this lab, you will Create a function to match the specifications Use floating-point value division Instructions A pedometer treats walking 2,000 steps as walking 1 mile. It assumes that one step is a bit over 18 inches (1 mile = 36630 inches, so the pedometers assume that one step should be 18.315 inches). Let's customize this calculation to account for the size of our stride. Write a program whose input is the number of steps and the length of the step in inches, and whose output is the miles walked. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print(f'{your_value:.2f}') Ex: If the input is: 5345 18.315 the output is: You walked 5345 steps which are about 2.67 miles. Your program must define and call the following function. The function should return the number of miles walked.def steps_to_miles(user_steps, step_length) # Define your function here if __name__…arrow_forwardFunction SecondsToMinutes(float totalSecs) returns float resultMins // Calculate resultMins: resultMins = 0 Function Main() returns nothing float userSecs float resultMins userSecs = Get next input resultMins = SecondsToMinutes(userSecs) Put userSecs to output Put " seconds are " to output Put resultMins to output Put " minutes." to outputarrow_forward
- C++ Coding: ArraysTrue and False Code function definitions for eoNum() and output(): Both eoNum() and output() are recursive functions. output() stores the even/odd value in an array. Store 0 if the element in the data array is even and store 1 if the element in the data array is odd. eoNum() displays all the values in an array to the console.arrow_forwardProgramming Language: C++ 4. Select the two correct statements about stub functions: Select one or more: a. stubs are used to test the functionality of a program b. stubs must return a value c. stubs are programs that test if a called function returns the correct result d. stubs are simpler than the functions they replacearrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY