Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6.5, Problem 6.9CP
What is the output of the following
#include <iostream>
using namespace std;
void fund1(double, int); // Function prototype
int main()
int x = 0;
double y = 1.5;
cout << x << " " << y << endl;
func1(y, x);
cout << x << " " << y << endl;
return 0;
}
void fund (double a. int b)
{
cout ,<< a << " " << b << endl;
a = 0.0;
b = 10;
cout << a << " " << b << endl:
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Please help me explain the following void function c++ code, which I did not understand. Especially for the first void function and int main(), I do not understand why the first void function enter the number and the int main function print out the final answer.
#include <iostream>using namespace std;
void getNumber(int *input); void doubleValue(int *val);
int main(){ int number; getNumber(&number); doubleValue(&number); cout<<"That value doubled is"<<number<<endl; return 0;}void getNumber(int *input){ cout<<"Enter an integer number:"; cin>>*input; }void doubleValue(int *val){ *val *=2;}
In C++,
Given the following function prototype:
void testDefault(int a, int b = 7, char z = '*');
Indicate if each of the following function calls are valid or invalid
a) testDefault(5);
b) testDefault();
c) testDefault(6, '#');
d) testDefault(0, 0, '?');
Assume that the declarations for two functions look as follows:
int Function1(double x);
2.void Function2(double x);
Give some sample code that would show how each function could be used.
Chapter 6 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 6.2 - Use the following information to answer questions...Ch. 6.2 - Use the following information to answer questions...Ch. 6.2 - Prob. 6.3CPCh. 6.2 - Use the following information to answer questions...Ch. 6.2 - Use the following information to answer questions...Ch. 6.2 - Use the following information to answer questions...Ch. 6.5 - Indicate which of the following is the function...Ch. 6.5 - A) Write the function header for a function named...Ch. 6.5 - What is the output of the following program?...Ch. 6.5 - The following program skeleton asks for the number...
Ch. 6.9 - How many return values may a function have?Ch. 6.9 - Write a header for a function named distance. The...Ch. 6.9 - Write a header for a function named days. The...Ch. 6.9 - Prob. 6.14CPCh. 6.9 - Write a header for a function named lightYears....Ch. 6.11 - What is the difference between a static local...Ch. 6.11 - Prob. 6.17CPCh. 6.11 - Prob. 6.18CPCh. 6.13 - Prob. 6.19CPCh. 6.13 - Write the prototype and header for a function...Ch. 6.13 - Write the prototype and header for a function...Ch. 6.13 - What is the output of the following program?...Ch. 6.13 - The following program asks the user to enter two...Ch. 6.15 - Is it required that overloaded functions have...Ch. 6.15 - What is the output of the following program code?...Ch. 6.15 - What is the output of the following program code?...Ch. 6 - The ____ is the part of a function definition that...Ch. 6 - If a function doesnt return a value, the word...Ch. 6 - If function showValue has the following header:...Ch. 6 - Either a functions ____ or its ____ must precede...Ch. 6 - Values that are sent into a function are called...Ch. 6 - Special variables that hold copies of function...Ch. 6 - When only a copy of an argument is passed to a...Ch. 6 - A(n)_____ eliminates the need to place a function...Ch. 6 - A(n)_____ variable is defined inside a function...Ch. 6 - ____ variables are defined outside all functions...Ch. 6 - _____ variables provide an easy way to share large...Ch. 6 - Unless you explicitly initialize numeric global...Ch. 6 - If a function has a local variable with the same...Ch. 6 - ______ local variables retain their value between...Ch. 6 - The _____ statement causes a function to end...Ch. 6 - ______ arguments are passed to parameters...Ch. 6 - When a function uses a mixture of parameters with...Ch. 6 - Prob. 18RQECh. 6 - When used as parameters, _______ variables allow a...Ch. 6 - Reference variables are defined like regular...Ch. 6 - Reference variables allow arguments to be passed...Ch. 6 - The ________ function causes a program to...Ch. 6 - Two or more functions may have the same name, as...Ch. 6 - What is the advantage of breaking your...Ch. 6 - What is the difference between an argument and a...Ch. 6 - When a function accepts multiple arguments, does...Ch. 6 - What does it mean to overload a function?Ch. 6 - If you are writing a function that accepts an...Ch. 6 - Give an example of where an argument should he...Ch. 6 - How do you return a value from a function?Ch. 6 - Prob. 31RQECh. 6 - Prob. 32RQECh. 6 - The following statement calls a function named...Ch. 6 - A program contains the following function, int...Ch. 6 - Write a function, named timesTen, that accepts an...Ch. 6 - A program contains the following function. void...Ch. 6 - Write a function named getNumber, which uses a...Ch. 6 - Write a function named biggest that receives three...Ch. 6 - Prob. 39RQECh. 6 - Markup Write a program that asks the user to enter...Ch. 6 - Celsius Temperature Table The formula for...Ch. 6 - Falling Distance The following formula can be used...Ch. 6 - Kinetic Energy In physics, an object that is in...Ch. 6 - Winning Division Write a program that determines...Ch. 6 - Shipping Charges The Fast Freight Shipping Company...Ch. 6 - Prob. 7PCCh. 6 - Lowest Score Drop Write a program that calculates...Ch. 6 - Star Search A particular talent competition has...Ch. 6 - isPrime Function A prime number is an integer...Ch. 6 - Present Value Suppose you want to deposit a...Ch. 6 - Future Value Suppose you have a certain amount of...Ch. 6 - Stock Profit The profit from the sale of a stock...Ch. 6 - Multiple Stock Sales Use the function that you...Ch. 6 - Order Status The Middletown Wholesale Copper Wire...Ch. 6 - Overloaded Hospital Write a program that computes...Ch. 6 - Population In a population, the birth rate is the...Ch. 6 - Transient Population Modify Programming Challenge...Ch. 6 - Using FilesHospital Report Modify Programming...Ch. 6 - Group Project 20. Using FilesTravel Expenses This...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Look at the following class definitions: class Vegetable { public virtual void message() { MessageBox. Show (I ...
Starting out with Visual C# (4th Edition)
When displaying a Java applet, the browser invokes the _____ to interpret the bytecode into the appropriate mac...
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Use what you've learned about the binary numbering system in this chapter to convert the following decimal numb...
Starting Out with Python (4th Edition)
Write a program to print the value of EOF.
C Programming Language
Why do many programming languages implement I/O operations as if they were calls to functions?
Computer Science: An Overview (12th Edition)
What is a control structure?
Starting Out with Python (3rd Edition)
Knowledge Booster
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
- I need help in creating 5 user defined function in C to solve the following problem as shown in the screenshot. Below is the skeleton code for the problem. The 5 user defined functions need to be created in accordance to the screenshot and should be tested in the int main function. The Skeleton Code #include <stdio.h>#include <string.h> typedef char String30[31];typedef char String60[61]; /* TO DO: Implement the functions as specified in screenshot above RESTRICTIONS: 1. Do NOT call printf() or scanf() in any of the required function definition EXCEPT in the main() function. */ /* Step 1: Define the function that will achieve this step right after this comment. Do NOT call print(), scanf() and any other library functions not indicated above. User defined function has to be made in accordance to step 1 in the screenshot */ /* Step 2: Define the function that will achieve this step right after this comment. Do…arrow_forwardI need help making a code be modular, with a function prototype, function definition and function call. Any help on this matter would be greatly appreciated. #include <iostream> using namespace std; double employeePay(double hours, double payRate, double grossPay);double grossPay(double hours, double payRate); int main(){ double hours = 0; double payRate = 0; double grossPay = 0; { while (hours > 40 || hours <= 0) { cout<<"Enter hours between 0-40"<<endl; cout <<"Enter the number hours worked: " ; cin >> hours; } while (payRate > 18.25 || payRate <= 7.5) { cout <<"Pay type must be between $7.50 and $18.25" << endl; cout <<"Enter the pay: " ; cin >> payRate; } { int grossPay = (hours * payRate); cout <<"The gross pay is $" << grossPay; } } }arrow_forward1. Write a program in python that contains a main function and a custom, void function named show_larger that takes two random integers as parameters. This function should display which integer is larger and by how much. The difference must be expressed as a positive number if the random integers differ. If the random integers are the same, show_larger should handle that, too. See example outputs. In the main function, generate two random integers both in the range from 1 to 5 inclusive, and call show_larger with the integers as arguments.EXAMPLE OUTPUT 13 is larger than 1 by 2EXAMPLE OUTPUT 2The integers are equal, both are 3arrow_forward
- Engineers often measure the ratio of two power measurements in decibels, or dB, which can be calculated as follows:dB= log10P2/P1Where P2 is the power level being measured, and P1 is some reference power level. Write a c++ programe contain function that calculates the level. The function’s prototype is as follows:double dBCalculator (double P1, double P2);Then, call dBCalculator from the main function to find the power ratio for the measurements from 1 to 20 Watts, in 2 Watt steps. You can assume that the reference power P1 is 1 Watt.arrow_forwardIn c++ In terms of testing and debugging functions, define stubs and drivers. Create a driver for the function you created in the previous volume problem. Show your source code and a sample of the program output. Does your function produce accurate results? previous code: #include <iostream>#include <cmath>using namespace std;const float PI = 3.14; float ConeVolume(float radius, float height){ return (PI / 3) * pow(radius, 2) * height;} int main(){ float radius, height, volume; cout << "Enter the radius: "; cin >> radius; cout << "Enter the height: "; cin >> height; volume = ConeVolume(radius, height); cout << "The volume of the cone is: " << volume << endl; return 0; }arrow_forwardC programming Q1) Write a function called letter grade that has a type int input parameter called points andreturns through an output parameters gradepLetter and gradepNumber. The appropriate lettergrade matching is given in the table below. Return through a second output parameter(just_missedp) an indication of whether the student just missed the next higher grade (true for89, 79, 64 and so on).Prototype: void letter_grade(int points, char *gradepLetter, char*gradepNumber, char *just_missedp);arrow_forward
- In C programming, if the return type of a function is Void how can you implement assert statements? For example, Void ceasar(int n, char*x); //if char = c and n = 3 output == f how do i use assert statements as this does not work assert (caesar(3,c)==f);arrow_forward/*Modify this code to change the functions double AreaOfCircle(double radius=1);double AreaOfRectangle(double l=1, double w=1);INTOone overloaded function named Area and set the defaults parameters to 0*/#include <iostream>using namespace std; void PrintMenu();double AreaOfCircle(double radius=1);double AreaOfRectangle(double l=1, double w=1); int main(){double radius,length,width,side;int option;do {//Call PrintMenuPrintMenu();cin>>option;switch(option){case 1: cout << "Enter radius";cin >> radius;cout << "Area of circle with radius 1 is : "<< AreaOfCircle()<<endl;cout << "Area of circle with radius : "<< radius <<" is "<< AreaOfCircle(radius)<<endl;break;case 2: cout << "Enter length and width: ";cin >> length>>width;cout << "Area of Rectangle with length=1 and width =1 "<< " is "<< AreaOfRectangle()<<endl;cout << "Area of Rectangle with length "<< length…arrow_forwardModify this code to change the functions double AreaOfCircle(double radius=1);double AreaOfRectangle(double l=1, double w=1);INTOone overloaded function named Area and set the defaults parameters to 0 #include <iostream>using namespace std; void PrintMenu();double AreaOfCircle(double radius=1);double AreaOfRectangle(double l=1, double w=1); int main(){double radius,length,width,side;int option;do {//Call PrintMenuPrintMenu();cin>>option;switch(option){case 1: cout << "Enter radius";cin >> radius;cout << "Area of circle with radius 1 is : "<< AreaOfCircle()<<endl;cout << "Area of circle with radius : "<< radius <<" is "<< AreaOfCircle(radius)<<endl;break;case 2: cout << "Enter length and width: ";cin >> length>>width;cout << "Area of Rectangle with length=1 and width =1 "<< " is "<< AreaOfRectangle()<<endl;cout << "Area of Rectangle with length "<< length…arrow_forward
- Write a function prototype to calculate the volume of a cube. The function receives a long type variable that stores one of the side of the cube and returns the long type volume of the cubearrow_forwardImplement in C Programming 6.20.1: Lab training: Unit tests to evaluate your program Complete a program that takes a weight in kilograms as input, converts the weight to pounds, and then outputs the weight in pounds. 1 kilogram = 2.204 pounds (lbs). Ex: If the input is: 10 the output is: 22.040000 lbs Note: Your program must define the functiondouble KiloToPounds(double kilos) The program below has an error in the KiloToPounds() function. Try submitting the program for grading (click "Submit mode", then "Submit for grading"). Notice that the first two test cases fail, but the third test case passes. The first test case fails because the program outputs the result from the KiloToPounds() function, which has an error. The second test case uses a Unit test to test the KiloToPounds() function, which fails. Change the KiloToPounds() function to multiply the variable kilos by 2.204, instead of dividing. The return statement should be: return (kilos * 2.204); Submit again. Now the test…arrow_forward4. Write a function named Quotient with 2 Integer parameters (originally from text boxes) and a Double return type in VB.NET. The function should calculate the first parameter divided by the second and return the result.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License