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 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…
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.
-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)
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
Your country is at war and your enemies are using a secret code to communicate with one another. You have manag...
Java: An Introduction to Problem Solving and Programming (7th Edition)
(Reverse an array) The reverse method in Section 7.7 reverses an array by copying it to a new array. Rewrite th...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
#inc1ude iostream #inc1ude string using namespace std; int main() { cout string("fantastic").size(); return 0;...
Starting Out with C++: Early Objects
Employee Class Modification In Programming Challenge 1 of Chapter 3, you wrote an Employee class. Add the follo...
Starting Out with Java: Early Objects (6th Edition)
What are the advantages and disadvantages of implicit declarations?
Concepts Of Programming Languages
Code an SQL statement that creates a table with all columns from the parent and child tables in your answer to ...
Database Concepts (7th 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
- 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_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_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_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_forward4. Which function calls would provide the most helpful test of this function? Remember: With tests, you are attempting to figure out all the possible ways the function could be broken. function findMin(num1, num2){ if(num1 < num2){ return num1; } else { return num2; } } function findMin (num1 num2 if( numl < num2 ) return numl } else ( return num2 O A. findMin(-1, 0) findMin(2,4) findMin(5,10) Ов. findMin(5,3) findMin(7,2) findMin(5,1) O C. findMin(1,1) findMin(-2,2) findMin(0,3) O D. findMin(-1,1) findMin(1,-1) findMin(1,1)arrow_forwardQuestion 2 Create a generic function sum that takes two integer/double numbers as parameters Not yet and prints the sum. answered Example: Marked out of sum(1.5, 3.5); sum(100, 200); // prints: 5 // prints: 300 2.00 P Flag question Submission instruction: Submit your code in the text editor below. Code must be indented. All the codes will be cross-checked for plagiarism and if found, both submissions will receive 0.arrow_forward
- ASSIGNMENT Consider the following function. What is the purpose of the function f? Please do explain and describe in details all possible answers for this function given below.int f(int n) {if ((a >= b) && (c < b)) return b; else if (a >= b) return f(a, c, b); else return f(b, a, c);} To find the maximum number between a, b, and c. To find the middle number between a, b, and c. To find the minimum number between a, b, and c. None of the other statements. Suppose the letters a,b,c,d,e,f have probabilities of 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. Which of the following is the Huffman code for the letter a,b,c,d,e,f? Please show how is the Huffman tree, so that you can determine one of the options below. 0, 10, 110, 1110, 11110, 11111 11, 10, 01, 001, 0001, 0000 11, 10, 011, 010, 001, 000 110, 100, 010, 000, 001, 111 An adjacency matrix of a graph is given below: matrix at photoFirst, draw the graph defined by that adjacency matrix, and label the…arrow_forwardIn C programming: Write a main() function using the following requirements:• Define a SIZE constant (the value is irrelevant, but for testing, you may want to keep it small enough – no bigger than 5)• Create an array of course pointers using SIZE• Dynamically allocate each element of the array• Call inputAllCourses()• Call printAllCourses().arrow_forwardConsider the following function. int my_func(int a) { return(a+3); } If the function is called using my_func(5), what will the function return?arrow_forward
- 1. A function that make use of reference parameters to share its output to the caller. The function has one of the parameter of type int , whose value is a 3 digit number, it must separate its digit And calculate the cube of each of its digit separately as output and share these cubes with its caller. Ø 2. A function that has no parameter but a char array initialized by some name. If the name starts and end at the same letter then function should return true, else return false. Ø 3. Write a main function to call the above two functions. NOTE: Program written in c++arrow_forwardCan the [] operator be defined as a nonmember function?arrow_forwardAssume that the following function prototypes are defined: void convertToCelsius(double *); void convertToFahrenheit(double &); In addition, let the following data be defined: const int N = 6; double temps[N] = {-459.67, -40.0, 0.0, 32.0, 98.6, 212.0}; double boilingPoint = 212.0; Write a function call that carries out each task described below. а. Convert boilingPoint to Celsius. b. Convert boilingPoint back to Fahrenheit. C. The freezing point is stored in the array temps, at index 3. Convert the freezing point stored in the temps array to Celsius. d. Convert the freezing point stored in the temps array back to Fahrenheit.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