C++ Quiz 4

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Tcarteronw
T
Tcarteronw
Community Contributor
Quizzes Created: 38 | Total Attempts: 32,005
| Attempts: 708 | Questions: 17
Please wait...
Question 1 / 17
0 %
0/100
Score 0/100
1. Match the following terms and definitions
Submit
Please wait...
About This Quiz
C++ Quiz 4 - Quiz

C++ Quiz 4 assesses knowledge of fundamental C++ programming concepts including type casting, function overloading, and standard library functions. It is designed to test understanding of syntax and... see morefunction usage, critical for learners aiming to master C++. see less

2. Match the following terms and definitions.
Submit
3. Match the following terms and definitions.
Submit
4. What is the output of the following program fragment? cout << static_cast<double>(3)/4 << endl;

Explanation

The program fragment is using static_cast to convert the integer value 3 to a double before dividing it by 4. Since both 3 and 4 are integers, the division will be performed as integer division, resulting in the quotient 0. However, since the numerator is now a double, the result of the division will be implicitly converted to a double, resulting in the output of 0.75.

Submit
5. The functions pow(), sqrt(), and fabs() are found in which include file?  

Explanation

The functions pow(), sqrt(), and fabs() are found in the cmath include file.

Submit
6. Information Hiding is analogous to using  

Explanation

Information hiding is a concept in software engineering that suggests hiding the implementation details of a module or component from other parts of the system. This is similar to using a black-box methodology, where the internal workings of the system are hidden and only the inputs and outputs are visible. By using a black-box methodology, the details of how the system functions are abstracted away, allowing for easier understanding and maintenance of the system as a whole. Similarly, information hiding allows for better modularization and encapsulation of code, making it easier to modify and maintain.

Submit
7. If you have the following variable declaration in your program, const int SIZE=34; then which of the following statements are legal?

Explanation

The statement "cout" is legal because it is used to display the value of the variable SIZE.

Submit
8. What is the value of the following? sqrt(sqrt(pow(2,4)));

Explanation

The given expression calculates the square root of the square root of 2 raised to the power of 4. First, 2 raised to the power of 4 is calculated, which equals 16. Then, the square root of 16 is taken, resulting in 4. Finally, the square root of 4 is calculated, which equals 2. Therefore, the value of the expression is 2.

Submit
9. Using functions in a program is known as  

Explanation

Procedural abstraction refers to the practice of using functions in a program. Functions allow us to break down complex tasks into smaller, more manageable parts, making the code easier to understand and maintain. By encapsulating a set of instructions within a function, we can reuse that code whenever needed, improving code reusability and reducing redundancy. Therefore, the correct answer is procedural abstraction.

Submit
10. The expression static_cast<double>(3) is called a  

Explanation

The expression static_cast(3) is called a type cast because it is used to explicitly convert the value 3 to the type double. Type casting allows for the conversion of one data type to another, and in this case, the integer value 3 is being converted to a double value. This is done by using the static_cast operator followed by the desired data type in angle brackets.

Submit
11. If the variable x has the original value of 3.4, what is the value in x after the following? cout << static_cast<int>(x);

Explanation

The static_cast(x) statement converts the value of x to an integer. Since x has the original value of 3.4, it will be converted to the nearest integer, which is 3. Therefore, the value in x after the statement is 3.

Submit
12. When parameters are passed between the calling code and the called function, parameters and arguments are matched by:

Explanation

When parameters are passed between the calling code and the called function, the matching of parameters and arguments is based on their relative positions in the parameter and argument lists. This means that the first parameter in the function's parameter list will be matched with the first argument in the calling code's argument list, the second parameter will be matched with the second argument, and so on. The matching is done based on the order in which the parameters and arguments are defined, regardless of their names or data types.

Submit
13. Which of the following are valid function calls to the pow function?  

Explanation

The only valid function call to the pow function is pow(1.1,3.0). This is because the pow function takes two arguments, both of which must be of type int or double. The first function call pow(int x, int y) is invalid because it does not provide the required second argument. The second function call pow(2) is also invalid because it does not provide the required first argument. The fourth function call double pow(1.1,3.0) is invalid because it includes the data type "double" before the function name, which is not allowed.

Submit
14. Which of the following are not legal function declarations?

Explanation

The function declaration "int 3ave(int a, int b, int c);" is not legal because function names cannot start with a number.

Submit
15. Which of the following functions is a properly overloaded function of the following?   int doSomething(int first, float second);

Explanation

The correct answer is "int doSomething(int first, int second, float third)" because it has the same function name "doSomething" and the same parameter types "int, int, float" as the original function. Overloading a function means creating a new function with the same name but different parameters.

Submit
16. If you have the two functions as shown,      int someFunction(int value);      float someFunction(float value); and a variable x, which is a double, which function is called by the following statement?      cout << someFunction(x);

Explanation

The statement cout

Submit
17. Which of the following are valid function calls to the fabs function?  

Explanation

The function call fabs(3.5) is valid because it calls the fabs function with the argument 3.5, which returns the absolute value of 3.5. The function call cout is also valid because it is used to output data to the console. However, the other function calls are not valid. The function call cin >> fabs(3.5) is invalid because the cin function is used for input, not for calling a function. The function call fabs(cin >> x) is also invalid because it tries to use the cin function as an argument for the fabs function, which is not allowed. The function call cout > fabs(3.5) is invalid because the > operator is used instead of the

Submit
View My Results

Quiz Review Timeline (Updated): Feb 17, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Feb 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jun 02, 2013
    Quiz Created by
    Tcarteronw
Cancel
  • All
    All (17)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Match the following terms and definitions
Match the following terms and definitions.
Match the following terms and definitions.
What is the output of the following program fragment? ...
The functions pow(), sqrt(), and fabs() are found in which include...
Information Hiding is analogous to using  
If you have the following variable declaration in your program, ...
What is the value of the following? sqrt(sqrt(pow(2,4)));
Using functions in a program is known as  
The expression static_cast<double>(3) is called a  
If the variable x has the original value of 3.4, what is the value in...
When parameters are passed between the calling code and the called...
Which of the following are valid function calls to the pow function? ...
Which of the following are not legal function declarations?
Which of the following functions is a properly overloaded function of...
If you have the two functions as shown, ...
Which of the following are valid function calls to the fabs function? ...
Alert!

Advertisement