Given the following heading for a user-defined function, what would be the correct way to call...
Assume a function named findMin has been defined to return the Index position of the smallest value in an array of double values. Which of the following would be the correct way to call the findin function from main, given the following array definition: double areas () - (5.2. 12.3, 7.0.3.4, 6,8); a, int smallloc = findMin ( areas); b. int smallloc - findMin ( areas [1.5); c. int small.oc - findMin ( areas, 5); d. double smallloc = find...
Assume a function named find Min has been defined to return the index position of the smallest value in an array of double values. Which of the following would be the correct way to call the findMin function from main , given the following array definition: double areas [ ] = {5.2. 12.3, 7.0, 3.4, 6.8 }; a. int smallLoc = findMin ( areas); b. int smallLoc = findMin ( areas [ ],5); O c. int smallLoc = findMin (...
The function used in the following program is supposed to take 2 parameters (arguments) and switch the contents of the 2 and send them back to the calling program, but the values are not swapped and both have the same number in them. Select the option that fixes the problem? void interchange(int &arg1, int &arg2) { arg2 = arg1; arg1 = arg2 ; } int main() { int num1 = 4 , num2 = 5; interchange(num1, num2); cout << "Number...
A student has written the following user-defined function to compute the total cost of a dinner for some number of guests. The parameters for this function are the cost per meal (a double) and the number of guests (an integer). There seem to be some errors in the code--what are they? Code written by the student: int dinnerCost ( double mealCost, guests) int total = mealCost * guests; The student failed to declare the datatype of guests as int in...
1. A(n) ____________________ is a variable or expression listed in a call to a function. 2. The pass by ____________________ mechanism must be used if the calling code is to receive information back from the function. 3. True or False? If there are several items in a parameter list, the compiler matches the parameters and arguments by their relative positions in the parameter and argument lists. 4. True or False? In C++, a function definition may have another function definition...
Suppose the following variable are defined in a function, char line[80], comm[20], p1[20], p2[20]; int n; Where line is the complete line entered by the user, comm is the first word on the line, p1 and p2 are the second and third words (if present), and n is the number of words on the line. If you were to pass these to a function called breakup, what would the function call look like? What would the function header look...
please write the procedure how you got the answer 30 and 31
Use the program below for problems 30 - 31 #include<stdio.h> int calcfactorial (int, int, int); int main() printf("result: %d\n", calcfactorial (7, 2, 5)); return(0); int calcfactorial(int n, int a, int b) int fact = 1; if(n > 1) if (n >= a && n <= b) fact = n* calcfactorial(n - 1, a, b); else fact = calcfactorial(n - 1, a, b); return(fact); 30. Which of the following...
What is the output of the call to the mystery function mystery
(100);?
What is the output of the call to the mystery function mystery(100);? public int mystery (int number){if(number 0) return 1; else return 1*mystery(number-1);} a.100 + 99 + ... + 1 b. 100 ! c. 100 d. None of the above
81. The following function call doesn’t agree with its prototype: cout << BoxVolume( 10, 5 ); int BoxVolume(int length = {1}, int width = {1}, int height = {1}); T__ F__ 82. The following function is implemented to swap in memory the argument-values passed to it: void swap(int a, int b) { int temp; temp = a; a = b; b = temp; ...
Consider the following program: # include <iostream> using namesapce std; void Func(int a, int bl double number-25.0: int main) f int x-18, y-20; cout<c"Before: x- kex<" and y-eyecendl; Fundxy 1// end of main void Funcfint a, int b) int sum a+b; a-200; b-300; numberanumber+1.0 Which of the statements below are correct? (Select only the correct answers. There may be more than one) D A The statement double number-25.0; declares a global variable number B. The variables x and y are...