Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6.13, Problem 6.22CP
What is the output of the following
#include <iostream>
using namespace std;
void test(int = 2, int = 4, int = 6);
int main()
{
test();
test(6);
test(3, 9);
test(1, 5, 7);
return 0;
}
void test (int first, int second, int third)
{
first += 3;
second += 6;
third += 9;
cout ≪ first ≪ " " ≪ second ≪ " " ≪ third ≪ endl;
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What will be the output of the following program in C++?
#include <iostream>using namespace std;class Test{static int x;public:Test() { x++; }static int getX() {return x;}};int Test::x = 0;int main(){cout << Test::getX() << " ";Test t[5];cout << Test::getX();}
1) Replace (????) with relevant code for the program to function. Details of the code have been given below. (Java has been used) Show your output.
This program should display:
2 -2 3
16 13 11 10 0
-10
*/
package finalexamtakehome5;
public class Finalexamtakehome5 {
//
public static void the(int x, int y) {
while (x > 0 | y > 0) {
x = x - y;
y--;
System.out.print(x + " ");
}
System.out.println(y);
}
//
public static void main(String[] args) {
theWhile(????);
theWhile(20, 4);
theWhile(40, -10, 7, 9);
}
}
Determine the output for the following code. Box in your final output result.
public class Beta extends Baap
{
public int h = 44;
public int getH( )
{
System.out.println("Beta " + h);
return h;
}
public static void main(String[ ] args)
{
Baap b = new Beta();
System.out.println(b.h + " " + b.getH( ));
Beta bb = (Beta) b;
System.out.println(bb.h + " " + bb.getH( ));
}
}
public class Baap
{
public int h = 4;
public int getH( )
{
System.out.println("Baap " + h);
return h;
}
}
Chapter 6 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Ch. 6.2 - Is the following a function header or a function...Ch. 6.2 - Is the following a function header or a function...Ch. 6.2 - What will the output of the following program be...Ch. 6.2 - The following program skeleton determines whether...Ch. 6.6 - Indicate which of the following is the function...Ch. 6.6 - Write a function named timesTen. The function...Ch. 6.6 - Write a function prototype for the timesTen...Ch. 6.6 - Prob. 6.8CPCh. 6.6 - What is the output of the following program?...Ch. 6.6 - 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 - Write a header for a function named getKey. The...Ch. 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 - What is the output of the following program?...Ch. 6.15 - What is the output of the following program?...Ch. 6 - Why do local variables lose their values between...Ch. 6 - What is the difference between an argument and a...Ch. 6 - Where do you define parameter variables?Ch. 6 - If you are writing a function that accepts an...Ch. 6 - When a function accepts multiple arguments, does...Ch. 6 - How do you return a value from a function?Ch. 6 - What is the advantage of breaking your...Ch. 6 - How would a static local variable be useful?Ch. 6 - Give an example where passing an argument by...Ch. 6 - The_______ is the part of a function definition...Ch. 6 - If a function doesnt return a value, the word...Ch. 6 - Either a functions _______ or its _______ must...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...Ch. 6 - A(n) _______ variable is defined inside a function...Ch. 6 - _______ variables are defined outside all...Ch. 6 - _______ variables provide an easy way to share...Ch. 6 - Unless you explicitly initialize global variables,...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. 26RQECh. 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 - Examine the following function header, then write...Ch. 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 that uses a...Ch. 6 - T F Functions should be given names that reflect...Ch. 6 - Prob. 39RQECh. 6 - T F Function prototypes are terminated with a...Ch. 6 - T F If other functions are defined before main,...Ch. 6 - T F When a function terminates, it always branches...Ch. 6 - T F Arguments are passed to the function...Ch. 6 - T F The scope of a parameter is limited to the...Ch. 6 - T F Changes to a function parameter always affect...Ch. 6 - T F In a function prototype, the names of the...Ch. 6 - T F Many functions may have local variables with...Ch. 6 - T F Overuse of global variables can lead to...Ch. 6 - T F Static local variables are not destroyed when...Ch. 6 - T F All static local variables are initialized to...Ch. 6 - T F Initialization of static local variables only...Ch. 6 - T F When a function with default arguments is...Ch. 6 - T F It is not possible for a function to have some...Ch. 6 - T F The exit function can only be called from...Ch. 6 - T F A stub is a dummy function that is called...Ch. 6 - Each of the following functions has errors. Locate...Ch. 6 - double average(int value1, int value2, int value3)...Ch. 6 - void area(int length =30, int width) { return...Ch. 6 - void getValue(int value) { cout "Enter a value:...Ch. 6 - (Overloaded functions) int getValue() { int...Ch. 6 - Markup Write a program that asks the user to enter...Ch. 6 - Rectangle AreaComplete the Program If you have...Ch. 6 - Winning Division Write a program that determines...Ch. 6 - Safest Driving Area Write a program that...Ch. 6 - Falling Distance When an object is falling because...Ch. 6 - Kinetic Energy In physics, an object that is in...Ch. 6 - Celsius Temperature Table The formula for...Ch. 6 - Coin Toss Write a function named coinToss that...Ch. 6 - Present Value Suppose you want to deposit a...Ch. 6 - Future Value Suppose you have a certain amount of...Ch. 6 - Lowest Score Drop Write a program that calculates...Ch. 6 - Star Search A particular talent competition has...Ch. 6 - Days Out Write a program that calculates the...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 - Paint Job Estimator A painting company has...Ch. 6 - Prob. 19PCCh. 6 - Stock Profit The profit from the sale of a stock...Ch. 6 - Multiple Stock Sales Use the function that you...Ch. 6 - isPrime Function A prime number is a number that...Ch. 6 - Prob. 23PCCh. 6 - Rock, Paper, Scissors Game Write a program that...Ch. 6 - Group Project 25. Travel Expenses This program...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
A(n) _____ is a set of well-defined steps for performing a task or solving a problem.
Starting Out With Visual Basic (7th Edition)
List the classes (n2), (log2n), (n), and (n3) in decreasing order of efficiency.
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
(Occurrences of each letter) Write a program that prompts the user to enter a file name and displays the occurr...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Practice Problem 8.5 (solution page 797) Write a wrapper function for sleep, called snooze, with the following ...
Computer Systems: A Programmer's Perspective (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
- Need code in C++ Write a program named Averages that includes a method named Average that accepts any number of numeric parameters, displays them, and displays their average. Test your function in your Main(). Tests will be run against Average() to determine that it works correctly when passed one, two, or three numbers, or an array of numbers. Method Average can average two numbers Method Average can average three numbers Method Average can average an array of numbers using static System.Console; public class Averages { public static void Main() { // Write your main here } }arrow_forwardplease help me with this c++ code, and I did not understand why the output is x=10 y=20. Please explain to me. #include<iostream> using namespace std; class Test { private: int x; int y; public: Test(int x = 0, int y = 0) { this->x = x; this->y = y; } Test &setX(int a) { x = a; return *this; } Test &setY(int b) { y = b; return *this; } void print() { cout << "x = " << x << " y = " << y << endl; } }; int main() { Test obj1(5, 5); // Chained function calls. All calls modify the same object // as the same object is returned by reference obj1.setX(10).setY(20); obj1.print(); return 0; }arrow_forwardI have a running code of a dining philosophers problem but it has a logic problem where it loops right after it asks how many of the philosophers are hungry thus unable to calculate how exactly the philosophers are going to eat below is the code: #include <stdio.h>#include <stdlib.h>#include <conio.h>#include <math.h>#include <string.h> void one(void);void two(void);void exit();int tph, philname[20], howhung, hu[20], cho;//{}[] int main(void){ int i, status[10],philname[10],howhung; printf("\n\nDINING PHILOSOPHER PROBLEM"); printf("\nEnter the total no. of philosophers: "); scanf("%d",&i); for(i=0;i<tph;i++) { philname[i] = (i+1); status[i]=1; } printf("How many are hungry : "); scanf("%d", &howhung); if(howhung==tph) { printf("\nAll are hungry..\nDead lock stage will occur"); printf("\nExiting.."); } else {…arrow_forward
- What will be the evaluation results of each of the following expressionshown by GHCi ? Briefly explain. HASKELL a. > [(x,y) | x <- [1,2], y <- [4,5]]b. > [(y,x) | x <- [1,2], y <- [4,5]]arrow_forwardThe steelwork.py program, given below, creates three types of steel objects. Carbon steel (Steel) is made of carbon and iron, alloy steel (AlloySteel) contains chromium in addition to carbon and iron. Stainless steel (StainlessSteel) contains nickel and a higher proportion of chromium. Write the missing code, in the designated locations (#TODO), in order for the program execution to yield the following output: ['Steel01', 0.6, 91] ['ALSteel02', 0.6, 91, 1] ['SSteel02', 0.6, 91, 11, 2]arrow_forwardFor the 8 Java statements below, identify each of the following statements as legal or illegal, and whether legal or not, state whether it represents a "narrowing" or "widening" conversion, or neither.arrow_forward
- . Write C++ statements for each of the following mathematics expressions.a. ? = ?3−? + 3 ÷ ?b. ? = √? + 2?c. ? =???2d. ? =???(5? + ?)e. ? =??−?5??3 − ?�arrow_forwardWhat is the data type of the variable cheap? What is the data type of the variable r? What is the data type of the variable r.price? For each of the 5 lines in the main code above (annotated #line 1, ..., #line 5), write below the method(s) of class Produce that are used in the execution of that line. If a line does not use (directly or indirectly) a method of class Produce, write N/A. Write the output of the code belowarrow_forwardWhat is the output of the following program? If no output, answer “no output”, “Runtime error”, or “Compiler error”. #include<iostream> using namespace std; class Base { public: void f() { cout<<”Base”; } }; class Derived;public Base { public: void f() { cout<<”Derived”; } }; main() { Base *base; Derived onj; base = &obj obj->f(); } Answer:arrow_forward
- What is the output of the following code: int main() { test1(); test1(); return 0; } void test1 () { static int x=2; int y = 8; cout<<x<<" "<<y<<endl; x+=2; y++; }arrow_forwardWhat is the output of the unit testing? #include <iostream>using namespace std;class TempConvert { public: void SetTemp(int tempVal) { temp = tempVal; } int GetTemp() const { return temp; } TempConvert() { temp = 1; } int InFahrenheit() { return (temp * 1.8) - 32; } private: int temp;};int main() { TempConvert testData; cout << "Beginning tests." << endl; if (testData.GetTemp() != 0) { cout << " FAILED initialise/get temp" << endl; } testData.SetTemp(10); if (testData.GetTemp() != 10) { cout << " FAILED set/get temp" << endl; } testData.SetTemp(10); if (testData.InFahrenheit() != 50) { cout << " FAILED InFahrenheit for 10 degrees" << endl; } cout << "Tests complete." << endl; return 0;} a. Beginning tests. FAILED initialise/get temp FAILED InFahrenheit for 10 degreesTests complete. b.…arrow_forwardIn a competition, following statements were given and Developers were told to mark the False one out of these statements: A. The output of the code print((1.1+2.2)==3.3) is returned False. B. The complex function converts complex(1.3) to (1.3+0j) C. The bin(2.3) returns the value as '0b10'. D. The function oct(3.0) throws TypeError.arrow_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
Call By Value & Call By Reference in C; Author: Neso Academy;https://www.youtube.com/watch?v=HEiPxjVR8CU;License: Standard YouTube License, CC-BY