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 14STE
Consider the following function definition:
void too2(int a[ ], int howMany) { for (int index = 0; index < howMany; index++) a[index] = 2; } |
Which of the following are acceptable function calls?
int myArray[29]; too2(myArray, 29); too2(myArray, 10); too2(myArray, 55); "Hey too2. Please, come over here." int yourArray[100]; too2(yourArray, 100); too2(myArray[3], 29); |
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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.
Write the function definition for a value returning function that receives an array of integer values, the array length, and an integer target value as parameters. The function should perform a li ear (sequencial) search for the target value. If the value is found, the function should return the index position of the target value, otherwise, it should return -1. Write only the function definition.
Consider 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…
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
2-1 List the five types of measurements that form the
basis of traditional ptane surveying-
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Why is it useful for a programmer to have some background in language design, even though he or she may never a...
Concepts Of Programming Languages
This is a design tool that describes the input, processing, and output of a function. a. hierarchy chart b. IPO...
Starting Out with Python (4th Edition)
Code an SQL statement that creates a table with all columns from the parent and child tables in your answer to ...
Database Concepts (8th Edition)
In Exercises 41 through 46, identify the errors.
Introduction To Programming Using Visual Basic (11th Edition)
Present Value Suppose you want to deposit a certain amount of money into a savings account, and then leave it a...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
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
- C code Blocks Write the complete function that receives a pointer to the array's first element as an argument and multiplies the third element of the array by 10. Define your function in the same way as the given function prototype. Take a look at the "For example" below to see how the function is used in the main function and the expected result. #include <stdio.h>#include <stdlib.h>void multiplyElement(int *ptr);int main(){ int array[5] = {1,2,3,4,5}; int *arrPtr = NULL; arrPtr = &array[0]; multiplyElement(arrPtr); for(int i = 0; i < 5; i++){ printf("%d ", array[i]); }return 0;}//Your answer starts here For example: Test Result int array[5] = {1,2,3,4,5}; int *arrPtr = NULL; arrPtr = &array[0]; multiplyElement(arrPtr); for(int i = 0; i < 5; i++){ printf("%d ", array[i]); } 1 2 30 4arrow_forwardC 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.00arrow_forwardThe correct function header that reference to array as function parameter (function increment contents of array passed as a parameter to it) Select one: a. void inc_array(int *arr) b. void inc_array(int arr) c. void inc_array(int &arr) d. void inc_array(int *arr[])arrow_forward
- -5- A PHP function is defined as follows: function planets ($arr) { if ($arr [1]) { print "Mercury"; } else { for ($i=0; $i <= $arr [2]; $i++) (print $arr [3] [$i]; } } print count ($arr); Recall that array $arr can be defined using a statement of the form: $arr array (...); Give an array $arr such that planets ($arr) prints Mercury O For this case, what is the output of the instruction print count ($arr); Give an array $arr such that planets ($arr) prints Venus o For this case, what is the output of the instruction print count ($arr); O Give an array $arr such that planets ($arr) prints Earth Jupiter Saturn. Note: the for loop must do three iterations in case (iii). -6- o For this case, what is the output of the instruction print count ($arr); 3. (a)arrow_forwardPYTHON 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.arrow_forward3. Write the appropriate function definition for each of the following situations:b) Write a function that computes two sums from the elements of an array of integers. Each element of the array contributes to one of the two sums, depending on whether the element itself is even or odd. Your function definition should look like this:void sum(int x[ ]){ int n;int sum_even;int sum_odd;::}arrow_forward
- 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_forwardPart A :Implement a function called min which takes a tuple of two numeric values and returns the lower value of the two.Implementation notes:• If needed, use Erlang function guards• Do NOT use the if or case structures Sample calls:> exam:min({3, 4}).3> exam:min({4, 3}).3 Part B:Implement at least three unique unit tests to test the min function created in Part A. Each testmust test a different aspect of the min function.Implementation notes:• An import for the Erlang Unit Test library is included in exam.erl• Use the Erlang Unit Test library to write the unit tests• Write each unit test in its own functionUpload• Include the unit test functions in exam.erl exam.erl file -module(exam). -compile(export_all). -include_lib("eunit/include/eunit.hrl").arrow_forwardWrite the appropriate function definition for each of the following situations: b) Write a function that computes two sums from the elements of an array of integers. Each element of the array contributes to one of the two sums, depending on whether the element itself is even or odd. Your function definition should look like this:void sum(int x[ ]){ int n;int sum_even;int sum_odd;::}arrow_forward
- C code blocks Write the complete function that receives a pointer to a single floating point number as an argument and returns that number after subtracting 100 from it. Define your function in the same way as the given function prototype. Take a look at the "For example" below to see how the function is used in the main function and the expected result. (For interest sake, note that this is a pass-by-reference function call.) #include <stdio.h>#include <stdlib.h>void subtractFunc(float *a);int main(){ float num = 357.900; subtractFunc(&num); printf("%.3f", num); return 0;} //Your answer starts here For example: Test Result float num = 357.900; subtractFunc(&num); printf("%.3f", num); 257.900arrow_forwardIn c++, write a function void zero(int a[], int size, int target) that sets all elements of a larger than target to zero. Include a sensible main function which calls the function and prints out the results.arrow_forwardc++ 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_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