Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 8P
Program Plan Intro
- Include required header files.
- Declaration of overload functions for “int”, “float”, “double” and “long”.
- Definition of “absolute()” function for “int”.
- Check “n” is lesser than “0”.
- Assign “-n” to the variable “v” for absolute value.
- Return “n”.
- Definition of “absolute()” function for “float”.
- Check “n” is lesser than “0”.
- Assign “-n” to the variable “v” for absolute value.
- Return “n”.
- Definition of “absolute()” function for “double”.
- Check “n” is lesser than “0”.
- Assign “-n” to the variable “v” for absolute value.
- Return “n”.
- Definition of “absolute()” function for “long”.
- Check “n” is lesser than “0”.
- Assign “-n” to the variable “v” for absolute value.
- Return “n”.
- Definition of “main()” function.
- Declare and initialize the variables for “int”, “float”, “double”, “long”.
- Call the overload “absolute()” functions and display the result.
- Check “n” is lesser than “0”.
- Assign “-n” to the variable “v” for absolute value.
- Return “n”.
- Check “n” is lesser than “0”.
- Assign “-n” to the variable “v” for absolute value.
- Return “n”.
- Check “n” is lesser than “0”.
- Assign “-n” to the variable “v” for absolute value.
- Return “n”.
- Check “n” is lesser than “0”.
- Assign “-n” to the variable “v” for absolute value.
- Return “n”.
- Declare and initialize the variables for “int”, “float”, “double”, “long”.
- Call the overload “absolute()” functions and display the result.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Can anyone solve this question in C++ using functions instead of libraries?
Please store emails and passwords of users in an array
Using C++
Using your own creativity, make a set of function templates that have these features:
This function must return a value.
A function template with 2 template parameters, T1 and T2.And, any other parameters you want
Within main ():
Call your template functions and demonstrate how they work.
Construct objects and show off your amazing programming skills!
For C++, why is it that reference values can change when given to a function? I understand that if you make a const reference parameter like:
double functionname(const point& p1)
then the function cannot attempt to make a change to the parameter.
Chapter 4 Solutions
Problem Solving with C++ (9th Edition)
Ch. 4.2 - Prob. 1STECh. 4.2 - Convert each of the following mathematical...Ch. 4.2 - Write a complete C++ program to compute and output...Ch. 4.2 - Write and compile short programs to test the...Ch. 4.3 - Prob. 5STECh. 4.3 - Prob. 6STECh. 4.3 - Prob. 7STECh. 4.3 - Prob. 8STECh. 4.3 - Carefully describe the call-by-value parameter...Ch. 4.3 - Prob. 10STE
Ch. 4.3 - Write a function definition for a function called...Ch. 4.3 - Write a function definition for a function called...Ch. 4.3 - Write a function definition for a function isDigit...Ch. 4.3 - Write a function definition for a function...Ch. 4.4 - What is the purpose of the comment that...Ch. 4.4 - Prob. 16STECh. 4.4 - Prob. 17STECh. 4.4 - Carefully describe the process of program testing.Ch. 4.4 - Prob. 19STECh. 4.5 - If you use a variable in a function definition,...Ch. 4.5 - Suppose a function named Function1 has a variable...Ch. 4.5 - The following function is supposed to take as...Ch. 4.5 - Prob. 23STECh. 4.6 - Prob. 24STECh. 4.6 - Prob. 25STECh. 4.6 - Prob. 26STECh. 4.6 - Suppose you have two function definitions with the...Ch. 4.6 - This question has to do with the Programming...Ch. 4.6 - Prob. 29STECh. 4 - A liter is 0.264179 gallons. Write a program that...Ch. 4 - Modify your program from Practice Program 1 so...Ch. 4 - The price of stocks is sometimes given to the...Ch. 4 - Write a program to gauge the rate of inflation for...Ch. 4 - Enhance your program from the previous Practice...Ch. 4 - Write a function declaration for a function that...Ch. 4 - The gravitational attractive force between two...Ch. 4 - Prob. 8PCh. 4 - Prob. 9PCh. 4 - Write a program that computes the annual after-tax...Ch. 4 - Write a program that asks for the users height,...Ch. 4 - Modify your program from Programming Project 2 so...Ch. 4 - Write a program that outputs the lyrics for the...Ch. 4 - To maintain ones body weight, an adult human needs...Ch. 4 - You have invented a vending machine capable of...Ch. 4 - Your time machine is capable of going forward in...Ch. 4 - Do Programming Project 11 from Chapter 3 except...
Knowledge Booster
Similar questions
- Suppose that you have the following recursive function written in C++. I've intentionally written the function so that it doesn't use descriptive names for anything, though that's obviously not a good design practice, but I aim not to bias your understanding of the techniques you'll be using by assuming anything about what the function's goal is; to stay "on task" here, you should resist the temptation to try to figure that out first. void kaboom( const std::vector& v, std::vector& w, unsigned int i) { if (i < w.size()) { int q = 0; for (int j : v) { q += j; } w.at(i) - kaboom(v, w, i + 1); } = q; } 1. Using the techniques from our discussion of the Asymptotic Analysis of Recursion, write a recurrence that describes the time required to run the following call to kaboom for two vector v and w whose sizes are the same. Use the variable s in your recurrence to denote that size. kaboom(v, w, 0) 2. Using the repeated substitution technique, reduce the recurrence to a closed form, then give…arrow_forwardUsing C++ Using your own creativity, make a set of function templates that have these features: This function must return a value. A function template with 1 template parameter, T. And, any other parameters you want. A function template with 2 template parameters, T1 and T2. And, any other parameters you want Within main (): Call your template functions and demonstrate how they work. Construct objects and show off your amazing programming skills!arrow_forwardIf you want to copy a shared pointer array into another array in C++, how do you do it? You've been handed a problem, and now you have to come up with creative answers. If you duplicate a shared pointer, does that mean you're also copying the objects that refer to it? Explainarrow_forward
- Is it preferable to divide the lengthy software into smaller modules, each of which performs a certain function? These chunks are referred to as functions in C++ programming. Do you have any other comments to make about this?arrow_forwardWhat is the method for storing local declarations in computer memory? Is there any reason to avoid using local declarations if the same objective can be achieved without them? Why use value parameters if reference parameters can be used in any function? What role do value parameters play in program data processing?arrow_forwardIn C++, what is the usage of the const and the static keyword, and how should I apply this to variables in OOP and functions? It is because I am having some trouble in learning how to use these two keywords, as I see them being used quite frequent and do not understand, but understand it theoratically.arrow_forward
- Using C++ Using your own creativity, make a set of function templates that have these features: This function must return a value. A function template with 1 template parameter, T. And, any other parameters you want. and then another function template but this time with 2 template parameters, T1 and T2. And, any other parameters you want.arrow_forwardI’m working in c++ and can’t find what to put for the return value! I need it to get my arrays set up so my other functions can sort them.arrow_forwardPLEASE CODE THIS IN C AND NOT C++. ONLY USE IF/CASE AND USER-DEFINED FUNCTIONS. PLEASE DO NOT USE LOOPS,STRUC, AND POINTERS. PLEASE ONLY DECLARE AND CALL VARIABLES IN THE MAIN FUNCTION, EVERYTHING ELSE IS IN A DIFFERENT USER-DEFINED FUNCTION. PLS CHECK IF IT WORKS TOO.arrow_forward
- Illustrate, by example, how a C++ struct may be passed as a parameter by value or by reference. Also, show how it can be returned from a function. Be thorough in your example and explain your code.arrow_forwardI know the concept of function and programming well so no need to explain all that. I want to know if I can call a function inside another function or not in c++? If yes, please provide precise and direct code.arrow_forwardwrite a code in c++ to solve any question using newton raphson method numerically but note that the use can change the function and error percentage and the values and take screenshot for the codearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education