Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
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
C PROGRAM
Reverse + Random Formula
In the code editor, there's already an initial code that contains the function declaration of the function, computeReverseNumber(int n) and an empty main() function.
For this problem, you are task to implement the computeReverseNumber function. This function will take in an integer n as its parameter. This will get the reverse of the passed integer and will then compute and return the value:
result = (original_number + reverse_of_the_number) / 3
In the main() function, ask the user to input the value of n, call the function computeReverseNumber and pass the inputted value of n, and print the result in the main() with two (2) decimal places.
SAMPLE:
Input n: 20
Output: 7.33
Input n: 123
Output: 148.00
Programming Language :- C
7. A function is defined for a positive integer n as follows:
3n + 1,
if n is odd
f(n) = {
n
if n is even
2
We consider the repeated application of the function starting with a given integer n, as follows:
f(n), f(f(n)), f(f(f(n))), It is conjectured that no matter which positive integer n you start
from; this sequence eventually will reach to 1. If n = 13, the sequence will be 13, 40, 20, 10, 5,
16, 8, 4, 2, 1. Thus if you start from n = 13, you need to apply function 10 times to reach 1.
Write a recursive function that takes n as an input number and returns how many times function
f has to be applied repeatedly to reach 1.
Consider the function definition:
void GetNums(int howMany, float& alpha, float& beta)
{
int i;
beta = 0;
for (i = 0; i < howMany; i++) {
beta = alpha + beta;
}
}
Describe what happens in MEMORY when the GetNums function is called.
Chapter 7 Solutions
Problem Solving with C++ (10th 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
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
Consider the following C program void fun (void) { int a, b, c; / defiinition.1 / . . . while (. . .) int b, c,...
Concepts Of Programming Languages
The file produced by the Java compiler containsthat are executed by the Java Virtual Machine.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Find the no-load value of υo in the circuit shown.
Find υo when RL is 150 Ω.
How much power is dissipated in th...
Electric Circuits. (11th Edition)
Repeat Practice Program 5 of Chapter 3, but use a loop so the user can convert other temperatures. If the user ...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Porter’s competitive forces model: The model is used to provide a general view about the firms, the competitors...
Management Information Systems: Managing The Digital Firm (16th 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
- float theRealQuestion (int x, float y) { int z; if (x > 15) z = x; else z = y; return z; } Code the function prototype for the given function.arrow_forwardConsider the following function main:Int main(){int inStock[10][4];int alpha [20];int beta[20];int gamma[4]= {11,13,15,17};int delta [10] = {3,5,2,6,10,9,7,11,1,8};} a) Write the definition of the function setZero that initializes any one-dimentional array of type int to 0.b) Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha.c) Write the definition of the function doubleArray that initializes the elements of beta to two times the corresponding elements of alpha. Make sure that you prevent the function from modifying the elements of alpha.d) Write the definition of the function copyGamma that sets the elements of the first row of inStock to gamma and the remaining rows of inStock to three times the previous row of inStock. Make sure that you prevent the function from modifying the elements of gamma.e) Write the definitions of the function copyAlphaBeta that stores alpha into the first five rows of inStock and beta…arrow_forwardfloat ACM (void); is non-void function with no parameters Select one: O True O Falsearrow_forward
- c++ computer language given the function header: void sum(int x=2, float y=3, int z =100) then which of the following is a valid function call? (choose all possible) a.sum(9); b.sum(a,b,5); c.sum(a,b); d.sum();arrow_forwardIn c++arrow_forwardUsing C++ Programming language: Assume you want a function which expects as parameters an array of doubles and the size of the array. Write the function header that accepts these parameters but is defined in such a way that the array cannot be modified in the function. You can use your own variable names for the parameters.arrow_forward
- python Define stubs for the functions get_user_num() and compute_avg(). Each stub should print "FIXME: Finish function_name()" followed by a newline, and should return -1. Each stub must also contain the function's parameters.Sample output with two calls to get_user_num() and one call to compute_avg():FIXME: Finish get_user_num() FIXME: Finish get_user_num() FIXME: Finish compute_avg() Avg: -1 i keep getting errors on this onearrow_forwardMULTIPLE FUNCTIONS AND RECURSIVE FUNCTIONS Use #include<stdio.h>arrow_forward#include<stdio.h> //Standard library math.h for Mathematics functions #include<math.h> //function declaration void function1(void); void function2(void); int main(void) { //calling both function function1(); function2(); printf("\nMain function for Ceil value: %f",ceil(4.5)); return0; } // Defining the first function void function1(void) { printf("\nFirst function for Square Root: %f",sqrt(91)); } //Defining the second function void function2(void) { printf("\nSecond function for Power: %f",pow(2,4)); } I need to do what the picture is asking for.arrow_forward
- 1. Square Flower You can have the turtle draw an interesting flower like sha pe by drawing n squares. Each n-square flower is drawn after turning the turtle by some number of degrees between each square. (see Figure 1 for an example) (a) Typel: A 5-square red flower. (b) A 15-square blue flower. Figure 1: Two types of n-square flowers Using the following implementation of draw square() function write a function na med draw flower() that takes a turtle, the number n of squares to draw, the side length and a color as parameters and draws an n-square flower by repeating the function draw square() n times. Test your code by drawing a yellow 21-square flower with side length of 200. def drav aqu ar e (aTurtle, sidelength): f or i in range (4) : aTurtle.forvard (side Length) aTurtle. 1eft (90)arrow_forwardhe function drawFractalLine is recursive. Write a script that draws the Koch snowflake. Define a function main that will draw a Koch snowflake with the following parameters when the program is run: Width = 200 Height = 200 Size = 150 Level = 4arrow_forward3A in Python language please: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 LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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