Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.... Which of the following functions correctly passes in a constant pass-by-va

ID: 3874305 • Letter: 1

Question

1....

Which of the following functions correctly passes in a constant pass-by-value vector of integers:

Select one:

a. void myFunction(const vector<int> nums)

b. void myFunction(const vector<int>& nums)

c. void myFunction(vector<int> const nums)

d. void myFunction(vector<const int>& nums)

2...

Which statement contains a common error or mistake with functions?

double AreaOfCircle(double radius) {

   const double pi = 3.14159265;

   double area = 0.0;

   double temp = 0.0;

   temp = pow(radius, 2);

   area = pi * temp;

   return radius;

}

Select one:

a. const double pi = 3.14159265;

b. temp = pow(radius, 2);

c. return radius;

d. No errors or mistakes.

3...Which warning message best describes the following code:

char GetInput() {

   char usr=’’;

   cin >> usr;

   if( !isalpha(usr) ) {

       usr = ‘a’;

   }

}

Select one:

a. Cannot assign a value inside a branch.

b. Control reaches end of non-void function.

c. Too many arguments to function ‘isalpha’.

d. If-statement expecting else statement.

4..

Why shouldn’t programmers write to pass-by-value parameters within a function?

Select one:

a. To avoid warning messages.

b. To avoid confusing a program’s reader.

c. To avoid pass-by-reference usage.

d. To avoid null parameters being assigned values.

5..

Determine whether the following is a valid beginning of a function definition.

double CalcAvg(double y, double y+1)

Select one:

a. Valid

b. Invalid

6..

What is the output of the following code?

int ConvToFtInch(int inch) {

   int inches = inch % 12;

   int feet = (inch-inches) / 12;

   return feet, inches;

}

int main() {

   int inches = 12;

   cout << ConvToFtInch(inches);

   return 0;

}

Select one:

a. No output. A function cannot have multiple return values;

b. 1

c. 1, 0

d. 12

7....

Local variables in the main function are the same as global variables.

Select one:

a. True

b. False

8..

Which type of loop will generates a compilation error when inside a function?

Select one:

a. while loop

b. for loop

c. do-while loop

d. None of the above

9...

What is the output of the following code?

int ConvertMinSecToSec(int minutes, int seconds=30) {

    return minutes*60 + seconds;

}

int main() {

   cout << ConvertMinSecToSec(3);

   return 0;

}

Select one:

a. Error: too few arguments to function ‘ConvertMinSecToSec’.

b. Inconsistent returned value ‘seconds’ in uninitialized.

c. 180

d. 210

10...

Which function will concatenate the char array firstName to the char array fullName?

Select one:

a. strcat(fullName, firstName);

b. strcmp(fullname, firstName);

c. strcpy(fullName, firstName);

d. strchr(fullname, firstName);

Please asnwer as soon as possible. Taking a test please

Explanation / Answer

1)Ans) void myFunction(const vector<int> nums)

2)Ans) b. temp = pow(radius, 2);

3)Ans) b. Control reaches end of non-void function.

4)Ans) b. To avoid confusing a program’s reader.

5)Ans)b. Invalid

6)Ans) a. No output. A function cannot have multiple return values;

7)Ans) b. False

8)Ans) d. None of the above

9)Ans) a. Error: too few arguments to function ‘ConvertMinSecToSec’.

10)Ans) a. strcat(fullName, firstName);

___________________Thank You