Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
9th Edition
ISBN: 9780133862218
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7.2, Problem 11STE
Consider the following function definition:
void tripler (int& n)
{
n = 3*n;
}
Which of the following are acceptable function calls?
int a[3] = {4, 5, 6}, number = 2;
tripler (number);
tripler (a[2]);
tripler (a[3]);
tripler (a[number]);
tripler (a);
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
PYTHON
You Define a Function
Part 1: Write a function that takes in one or two input parameters and returns an output. The function should return the output of a one-line expression. Write at least three test cases for your function in the docstring.
Make sure your function has just one line of code
Part 2: Write the same function as a lambda function.
Implement in C Programming
6.9.1: Function errors: Copying one function to create another.
Using the CelsiusToKelvin function as a guide, create a new function, changing the name to KelvinToCelsius, and modifying the function accordingly.
#include <stdio.h>
double CelsiusToKelvin(double valueCelsius) { double valueKelvin;
valueKelvin = valueCelsius + 273.15;
return valueKelvin;}
/* Your solution goes here */
int main(void) { double valueC; double valueK;
valueC = 10.0; printf("%lf C is %lf K\n", valueC, CelsiusToKelvin(valueC));
scanf("%lf", &valueK); printf("%lf is %lf C\n", valueK, KelvinToCelsius(valueK));
return 0;}
(Exponentiation) Write a function integerPower(base, exponent) that returns the value ofbaseexponentFor example, integerPower(3, 4) = 3 * 3 * 3 * 3. Assume that exponent is a positive, nonzero integer, and base is an integer. Function integerPower should use for to control the calculation. Donot use any math library functions.
Chapter 7 Solutions
Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
Ch. 7.1 - Prob. 1STECh. 7.1 - In the array declaration double score(5); state...Ch. 7.1 - Identity any errors in the following array...Ch. 7.1 - What is the output of the following code? char...Ch. 7.1 - What is the output of the following code? double a...Ch. 7.1 - What is the output of the following code? int i,...Ch. 7.1 - Prob. 7STECh. 7.1 - Suppose we expect the elements of the array a to...Ch. 7.1 - Prob. 9STECh. 7.1 - Suppose you have the following array declaration...
Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Prob. 12STECh. 7.2 - Write a function definition for a function called...Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Insert const before any of the following array...Ch. 7.2 - Write a function named outOfOrder that takes as...Ch. 7.3 - Write a program that will read up to ten...Ch. 7.3 - Write a program that will read up to ten letters...Ch. 7.3 - Following is the declaration for an alternative...Ch. 7.4 - Prob. 20STECh. 7.4 - Write code that will fill the array a (declared...Ch. 7.4 - Prob. 22STECh. 7 - Write a function named firstLast2 that takes as...Ch. 7 - Write a function named countNum2s that takes as...Ch. 7 - Write a function named swapFrontBack that takes as...Ch. 7 - The following code creates a small phone book. An...Ch. 7 - There are three versions of this project. Version...Ch. 7 - Hexadecimal numerals are integers written in base...Ch. 7 - Solution to Programming Project 7.3 Write a...Ch. 7 - Prob. 4PPCh. 7 - Write a program that reads in a list of integers...Ch. 7 - Prob. 6PPCh. 7 - An array can be used to store large integers one...Ch. 7 - Write a program that will read a line of text and...Ch. 7 - Write a program to score five-card poker hands...Ch. 7 - Write a program that will allow two users to play...Ch. 7 - Write a program to assign passengers seats in an...Ch. 7 - Prob. 12PPCh. 7 - The mathematician John Horton Conway invented the...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - A common memory matching game played by young...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Prob. 19PPCh. 7 - The Social Security Administration maintains an...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Why are constructors useful for performing start-up operations?
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
T F: If the CInt function cannot convert its argument, it causes a runtime error.
Starting Out With Visual Basic (7th Edition)
What arc the purposes of the two arguments needed for the write member function?
Starting Out with C++: Early Objects
The input operation that appears just before a validation loop is known as the ______. a. prevalidation read b....
Starting Out with Python (3rd Edition)
Open the house project from Chapter 1 and review the Picture class. What types of object are created by the con...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Describe two properties that each candidate key must satisfy.
Modern Database Management (12th 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
- Write a C++ function (along with helper functions) that prints out all the prime numbers in a given array of integers. The code should follow the exact function declaration: void printPrimes(int array[], int arr_size);arrow_forwardIn a function aFunction, we have 2 values: num1 (float type), num2 (int type) declared locally and assigned to 2.1 and 6. Write code segment to return the two values from function aFunction.arrow_forwardWrite and test the “digit” function:Function Prototype: int digit(int n,int k)This function returns the kth digit of the positive integer n. For example, if n is the integer 29,415, then the call digit(n,0) would return the digit 2, and the call digit(n,2) would return the digit 4.arrow_forward
- c++ computer language given the following class definition, write the definition of the function 'inc' such that it increases the variable 'tmp' by the amount received passed to the function. class temp { public: float inc(float); float dec(float); private: float tmp; };arrow_forward3. Write the appropriate function definition for each of the following situations:a) Write a function that separately sums the even indexed elements and old indexed elements of an array of doubles. Each element of the array contributes to one of the two sums, depending on whether the index of the element is even or odd. Your function definition must have a heading like this:void sum(double b[ ]){ int n;double *sum_even;double *sum_odd;::}arrow_forward1-The function sum_n_avg computes the sum and the average of three input arguments and relays its results through two output parameters.a)Write a prototype for a function sum_n_avg that accepts three double-type input parameters and returns two output parameters through reference.b)Write the function definition for function sum_n_avg. The function definition is where the actual computations are performed.c)Write a function call in main () for sum_n_avg. The function call can look like below:{double one, two, three, sum_of_3, avg_of_3;printf("Enter three numbers> ");scanf("%lf%lf%lf", &one, &two, &three);sum_n_avg(__________________________________);. . .}2- Write a function definition for a function named final_grade that has a typeint input parameter called points and returns through an output parameter gradePtr the appropriate letter grade using a straight scale (90–100 is an A, 80–89 is a B, and so on). Return through a second output parameter (missedPtr) an…arrow_forward
- In C++ Write the definition of a void function that has two parameters: an array, and an integer parameter that specifies the number of elements in the array. The functions swaps the first and last elements of the array.arrow_forwardC++ programming 48.In the function prototype void action(int& value); The argument value is said to be a ___________ parameter. 49.In the previous problem, suppose the function action updated its argument. True or false: the variable value in the caller would be updated. ________________ 50.True or false: the following two prototypes represent valid overloaded functions _________:double fna(double,int);float fna(float,int);arrow_forwardConsider the following function definition.void mystery(int* x){// function body } Inside the definition of mystery, the C++ language provides a way to distinguish if x points to a lone int value or to an int allocated as part of a larger array.A. True B. Falsearrow_forward
- Write a function prototype and a function definition called average that receives an array of type integer, and the number of elements in the array. It returns the average of the numbers in the array.arrow_forwardImplement in C Programming 6.10.1: Function pass by pointer: Transforming coordinates. Define a function CoordTransform() that transforms its first two input parameters xVal and yVal into two output parameters xValNew and yValNew. The function returns void. The transformation is new = (old + 1) * 2. Ex: If xVal = 3 and yVal = 4, then xValNew is 8 and yValNew is 10. #include <stdio.h> /* Your solution goes here */ int main(void) { int xValNew; int yValNew; int xValUser; int yValUser; scanf("%d", &xValUser); scanf("%d", &yValUser); CoordTransform(xValUser, yValUser, &xValNew, &yValNew); printf("(%d, %d) becomes (%d, %d)\n", xValUser, yValUser, xValNew, yValNew); return 0;}arrow_forwardWrite a function which accepts an int array and the number of elements in the array as two parameters. The function should dynamically create a new int array that is one element larger than the argument array. Element 0 of the new array should contain size, i.e. the number of elements in the argument array. Element 0 of the argument array should be copied to Element 1 of the new array, Element 2 of the argument array should be copied to Element 1 of the new array, etc. The function should return a pointer to the new array and should not modify the argument array. You may assume that the argument array contains at least one valid element and size is the number of elements in the array. You do not need to demonstrate calling this function. Example: if a[] is {2, 7, 4}, and size is 3, the function should return a pointer to a new array with 4 elements containing {3, 2, 7, 4}. int *counter(int a[], int size)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