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

C++ programming questions, most points to most complete answer 21. The following

ID: 3771777 • Letter: C

Question

C++ programming questions, most points to most complete answer

21. The following is legal in a void function:

return; (Points : 2)
True
False

Question 22.22. It is acceptable to have both call-by-value and call-by-reference parameters in the same function declaration. (Points : 2)
True
False

Question 23.23. The types of parameters are optional in the function declaration. (Points : 2)
True
False

Question 24.24. The compiler always pairs an else with the nearest previous if not already paired with an else. (Points : 2)
True
False

Question 25.25. It is illegal to make function calls inside a switch statement. (Points : 2)
True
False

Explanation / Answer

21)

TRUE

return ; is a legal statement in void functions;

it is mostly used in reccursion to exit the function when a boundarty case is reached

22)

True

yes , it is acceptable to have both call-by-value and call by reference

ex:

this is very common call we use both call-by-valueand call-by-reference is passing a array to a functipon

int function(int a[], int size) == int function(int *a, int size)

in the above function call , array is a call by reference parameter and size is a call by value parameter

23)

False

it is mandatory to specify the types of the parameters in function decleration

you can omit the parameter names but not types

int func(int, char) is valid

int func(i,c) is not valid

24)

False

compiler checks for paranthesis for this purpose

25)

False

it is legal to make function call inside switch statement

ex:

#include <iostream>
using namespace std;
int func1(int,char);
int main()
{
int j,i=1;
char c;
switch(i)
{
  
case 1:   
i=func1(j,c);
break;
}
}
int func1(int i,char c)
{
printf("Hai ");
return i;
}

output:

Hai

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote