C++ Programming Language Hardest Exam! Trivia Quiz

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: 31,980
| Attempts: 2,596
SettingsSettings
Please wait...
  • 1/90 Questions

    (T   F)  Another way to created a running total other than total = total + num is to write total += num.

    • True
    • False
Please wait...
About This Quiz

Below is what is considered the hardest trivia quiz on C++ programming language. It is designed for those of us who are studying towards passing the certification exam. Gaming developers mostly prefer the C++ language since it is fast. Are you feeling up to tackling this exam? Do give it a try and get to find out if you need more practice.

C++ Programming Language Hardest Exam! Trivia Quiz - Quiz

Quiz Preview

  • 2. 

    A library is a collection of program code that can be used by other programs.

    • True

    • False

    Correct Answer
    A. True
    Explanation
    A library is a collection of program code that can be used by other programs. This means that libraries contain pre-written code that can be utilized by developers in their own programs, saving them time and effort. By using libraries, developers can access functions, classes, or modules that have already been created and tested, allowing them to focus on other aspects of their program. Therefore, the statement "A library is a collection of program code that can be used by other programs" is true.

    Rate this question:

  • 3. 

    C++ programs should contain comments to explain the code.

    • True

    • False

    Correct Answer
    A. True
    Explanation
    Including comments in C++ programs is considered good practice because it helps in understanding and explaining the code. Comments provide additional information about the purpose, functionality, and logic of the code, making it easier for other developers (or even the original developer) to read and maintain the code. They can also serve as documentation for future reference. Therefore, it is recommended to include comments in C++ programs to enhance code readability and maintainability.

    Rate this question:

  • 4. 

    (T  F)  The following symbols represent OR:   &&.

    • True

    • False

    Correct Answer
    A. False
    Explanation
    The statement is false because the symbols "&&" represent AND, not OR. OR is represented by the symbol "||".

    Rate this question:

  • 5. 

    What is the value of x after the following statements? int x, y, z; y = 10; z = 3; x = y * z + 3;

    • Garbage

    • 60

    • 30

    • 33

    Correct Answer
    A. 33
    Explanation
    The value of x is 33 because the expression y * z + 3 evaluates to 33. The value of y is 10 and the value of z is 3, so when we multiply y and z we get 30, and then we add 3 to get the final result of 33.

    Rate this question:

  • 6. 

    Which of the following is not a phase of the program-design process?

    • Problem-solving

    • Implementation

    • Marketing the final program

    Correct Answer
    A. Marketing the final program
    Explanation
    The program-design process consists of several phases, including problem-solving, implementation, and marketing the final program. However, marketing the final program is not considered a phase of the program-design process. This phase typically occurs after the program has been designed and developed, and it involves promoting and advertising the program to potential users or customers. It focuses on creating awareness and generating interest in the program, rather than the actual design and development of the program itself.

    Rate this question:

  • 7. 

    C++ is not case-sensitive.

    • True

    • False

    Correct Answer
    A. False
    Explanation
    C++ is actually case-sensitive, meaning that it distinguishes between uppercase and lowercase letters. This means that variables, functions, and other identifiers must be written with consistent capitalization in order for the program to compile correctly. For example, "myVariable" and "myvariable" would be considered as two separate identifiers in C++. Therefore, the correct answer is False.

    Rate this question:

  • 8. 

    Str1 = "abc"; str2 = "xyz"; str3 = str1 + "-" +str2; Suppose that str1, str2, and str3 are string variables. After the statements above execute, the value of str3 is "_____".

    • Abc

    • Xyz

    • Abc-xyz

    • Xyz-abc

    Correct Answer
    A. Abc-xyz
    Explanation
    The given code declares three string variables, str1, str2, and str3. The value of str1 is "abc" and the value of str2 is "xyz". The code then concatenates str1, a hyphen "-", and str2 together using the + operator and assigns the resulting string to str3. So, after the statements execute, the value of str3 is "abc-xyz".

    Rate this question:

  • 9. 

    An “if” structure inside another “if” structure is called a:

    • Nested if

    • Dangling if

    • Boolean if

    Correct Answer
    A. Nested if
    Explanation
    A nested if structure refers to an if statement that is placed inside another if statement. It allows for more complex decision-making by providing multiple levels of conditions to be evaluated. This can be useful when certain conditions need to be met before checking additional conditions. By nesting if statements, the program can execute different blocks of code based on the combination of conditions being true or false.

    Rate this question:

  • 10. 

    (T  F) A function is invoked by a function call.

    • True

    • False

    Correct Answer
    A. True
    Explanation
    A function is a block of code that performs a specific task. It can be invoked or called by using its name followed by parentheses. When a function is invoked, the program jumps to that function and executes the code inside it. Therefore, a function is indeed invoked by a function call.

    Rate this question:

  • 11. 

    Which of the following data types may be used in a switch statement?

    • Int

    • Char

    • Enum

    • Long

    • All answers are correct

    Correct Answer
    A. All answers are correct
    Explanation
    In a switch statement, any of the given data types (int, char, enum, long) can be used. This is because a switch statement allows for multiple cases to be evaluated, and these data types can all be used as the expression to evaluate the cases. Therefore, all of the given answers are correct.

    Rate this question:

  • 12. 

    What is the output of the following code? float value; value = 33.5; cout << value << endl;

    • 33.5

    • 33

    • Value

    • Garbage

    Correct Answer
    A. 33.5
    Explanation
    The code initializes a variable named "value" with the value 33.5. Then, it prints the value of "value" followed by a line break. Therefore, the output of the code will be "33.5".

    Rate this question:

  • 13. 

    What is the output of the following program fragment? cout << pow(4,2) << endl;

    • 4

    • 2

    • 8

    • 16

    Correct Answer
    A. 16
    Explanation
    The program fragment uses the pow() function to calculate the result of raising 4 to the power of 2. The pow() function takes two arguments, the base (4 in this case) and the exponent (2 in this case), and returns the result of the exponentiation. The result, 16, is then printed to the console followed by a newline character.

    Rate this question:

  • 14. 

    When you type int main( ), it means that an integer will be returned.

    • True

    • False

    Correct Answer
    A. True
    Explanation
    When you type "int main( )", it means that the main function will return an integer value. In C++ and some other programming languages, the main function is the entry point of the program, and it is expected to return an integer value to indicate the status of the program execution. Therefore, the statement "an integer will be returned" is correct.

    Rate this question:

  • 15. 

    A variable assigned int can produce a number with decimals.

    • True

    • False

    Correct Answer
    A. False
    Explanation
    A variable assigned int cannot produce a number with decimals because int is a data type that represents whole numbers only. If we need to store numbers with decimals, we would use a different data type such as float or double.

    Rate this question:

  • 16. 

    An algorithm is

    • The inputs and outputs of a program

    • The part of the computer that does the processing

    • A finite set of steps to solve a problem

    • A complete computer program

    Correct Answer
    A. A finite set of steps to solve a problem
    Explanation
    The correct answer is "A finite set of steps to solve a problem". This answer accurately describes an algorithm, which is a precise and unambiguous set of instructions or steps that can be followed to solve a specific problem or perform a specific task. An algorithm can be implemented in any programming language and is independent of the inputs and outputs of a program, the processing unit of a computer, or being a complete computer program.

    Rate this question:

  • 17. 

    What is the value of x after the following code fragment executes? float x = 36.0; x = sqrt(x);

    • 36.0

    • 6.0

    • 3.0

    • 2.456

    Correct Answer
    A. 6.0
    Explanation
    The code fragment starts by initializing the variable x with the value 36.0. Then, the sqrt() function is applied to x, which calculates the square root of x. The square root of 36.0 is 6.0. Therefore, the value of x after the code fragment executes is 6.0.

    Rate this question:

  • 18. 

    Call-by-reference should be used

    • For all variables

    • When the function needs to change the value of one or more arguments

    • Never

    • Only in void functions

    Correct Answer
    A. When the function needs to change the value of one or more arguments
    Explanation
    Call-by-reference should be used when the function needs to change the value of one or more arguments. This is because call-by-reference allows the function to directly access and modify the original variables passed as arguments, rather than creating copies of them. By using call-by-reference, any changes made to the arguments inside the function will be reflected outside of the function as well. This is particularly useful when the function needs to update the values of variables in the calling code.

    Rate this question:

  • 19. 

    The following code: int *p; declares p to be a(n) ____ variable.

    • New

    • Num

    • Pointer

    • Address

    Correct Answer
    A. Pointer
    Explanation
    The given code declares a variable named "p" to be a pointer. A pointer is a variable that stores the memory address of another variable. In this case, "p" is declared as a pointer to an integer, as indicated by the use of the "*" symbol before the variable name.

    Rate this question:

  • 20. 

    The statement num is less than 10 or num is greater than 50 in C++ is written as _____.

    • Num < 10 or num > 50

    • (num < 10) or (num > 50)

    • Num < 10 || num > 50

    • Num < 10 && num > 50

    Correct Answer
    A. Num < 10 || num > 50
    Explanation
    The correct answer is "num < 10 || num > 50". This is the correct way to write the statement "num is less than 0 or num is greater than 50" in C++. The "||" operator is the logical OR operator, which checks if either condition is true. In this case, it checks if num is less than 10 or if num is greater than 50.

    Rate this question:

  • 21. 

    What is the output produced by the following segment of code? int x, y; y = 123; x = y + y; y = 19; cout << “ x = ” << x; cout << “ y = ” << y;

    • X = 246 y = 19

    • X = 246 y = 123

    • X = 38 y = 19

    • X = 38 y = 246

    Correct Answer
    A. X = 246 y = 19
    Explanation
    The code initializes two variables, x and y. It assigns the value 123 to y. Then, it assigns the value of y + y (which is 123 + 123 = 246) to x. After that, it assigns the value 19 to y. Finally, it prints the values of x and y. Therefore, the output will be "x = 246 y = 19".

    Rate this question:

  • 22. 

    The identifiers in the system-provided header files such as iostream, cmath, and iomanip are defined in the namespace _____.

    • Cctype

    • Stdl

    • Std

    • Stdlib

    Correct Answer
    A. Std
    Explanation
    The identifiers in the system-provided header files such as iostream, cmath, and iomanip are defined in the "std" namespace. The "std" namespace is used to avoid naming conflicts and to organize the code in a structured manner. By using the "std" namespace, the identifiers in these header files can be accessed using the scope resolution operator "::".

    Rate this question:

  • 23. 

    Assume you have the following declaration char nameList[100];. Which of the following ranges is valid for the index of the array nameList?

    • 0 through 99

    • 0 through 100

    • 1 through 100

    • 1 through 101

    Correct Answer
    A. 0 through 99
    Explanation
    The valid range for the index of the array nameList is from 0 through 99. This is because arrays in C/C++ are zero-indexed, meaning the first element of the array is at index 0 and the last element is at index n-1, where n is the size of the array. In this case, the array nameList has a size of 100, so the valid index range is from 0 to 99.

    Rate this question:

  • 24. 

    1. Which boolean operation is described by the following table?
    A B Operation True True True True False True False True True False False False

    • Or

    • And

    • Not

    • None of the above

    Correct Answer
    A. Or
    Explanation
    The correct answer is "or". This is because the operation returns "True" when at least one of the inputs is "True". In the given table, whenever either A or B is "True", the result is "True". Only when both A and B are "False", the result is "False".

    Rate this question:

  • 25. 

    The expression static_cast(3) is called a

    • Type cast

    • Multiplier

    • Doubler

    • Polymorphism

    Correct Answer
    A. Type cast
    Explanation
    The expression static_cast(3) is called a type cast. Type casting is a way to convert one data type into another. In this case, the static_cast is used to explicitly convert the value 3 into a different type.

    Rate this question:

  • 26. 

    If you need to write a function that will compute the cost of some candy, where each piece costs 25 cents, which would be an appropriate function declaration?

    • Int calculateCost(char name);

    • Char calculateCost(int count);

    • Int calculateCost int count;

    • Int calculateCost(int count);

    Correct Answer
    A. Int calculateCost(int count);
    Explanation
    The appropriate function declaration for computing the cost of candy would be "int calculateCost(int count);" because it takes an integer parameter "count" which represents the number of candy pieces, and it returns an integer value representing the total cost in cents. The other function declarations are not suitable because they either have the wrong parameter type or missing parameter type.

    Rate this question:

  • 27. 

    Testing your program should be done

    • As each function is developed

    • At the end of the coding

    • Only if there appear to be problems

    • Only if your instructor requires it.

    Correct Answer
    A. As each function is developed
    Explanation
    Testing your program should be done as each function is developed because it allows for early detection and resolution of any issues or bugs that may arise during the development process. By testing each function individually, it becomes easier to isolate and identify any errors, making the debugging process more efficient. Additionally, testing at this stage helps ensure that each function works correctly before moving on to the next one, ultimately leading to a more robust and reliable final program.

    Rate this question:

  • 28. 

    If the user types in the characters 10, and your program reads them into an integer variable, what is the value stored into that integer?

    • 1

    • 0

    • 10

    • None of the above

    Correct Answer
    A. 10
    Explanation
    When the user types in the characters "10", the program reads them into an integer variable. Since the characters "10" represent the numeric value of ten, the value stored into that integer variable will be 10.

    Rate this question:

  • 29. 

    It is possible when using a while loop that the body of the loop will never be executed.

    • True

    • False

    Correct Answer
    A. True
    Explanation
    In a while loop, the condition is evaluated before each iteration. If the condition is initially false, the body of the loop will never be executed. This can happen when the condition is set to an expression that is always false or when the loop control variable is not properly updated within the loop. Therefore, it is possible for the body of a while loop to never be executed.

    Rate this question:

  • 30. 

    Which boolean operation is described by the following table? A B Operation True True True True False False False True False False False False  

    • Or

    • And

    • Not

    • None of the above

    Correct Answer
    A. And
    Explanation
    The given table represents the boolean operation "and". In this operation, the result is true only when both inputs are true. In all other cases, the result is false.

    Rate this question:

  • 31. 

    In C++, you declare a pointer variable by using the ____ symbol.

    • *

    • &

    • #

    • @

    Correct Answer
    A. *
    Explanation
    In C++, you declare a pointer variable by using the "*" symbol. The "*" symbol is used to indicate that a variable is a pointer and can store the memory address of another variable. This allows you to indirectly access and manipulate the value of the variable that the pointer is pointing to.

    Rate this question:

  • 32. 

    A cin statement sends output to the computer screen.

    • True

    • False

    Correct Answer
    A. False
    Explanation
    The cin statement is used in programming languages like C++ to take input from the user, not to send output to the computer screen. It is used to read data from the standard input stream, which can be the keyboard or a file. Therefore, the given statement is incorrect, and the correct answer is False.

    Rate this question:

  • 33. 

    If an & is attached after the data type of a formal parameter, then the formal parameter is a _____.

    • Value parameter

    • Reference parameter

    • Global variable

    • Default variable

    Correct Answer
    A. Reference parameter
    Explanation
    If an "&" is attached after the data type of a formal parameter, it indicates that the formal parameter is a reference parameter. This means that the parameter will not create a new copy of the data when passed to a function, but rather it will refer to the same memory location as the argument that is passed to it. Any changes made to the reference parameter within the function will also affect the original argument outside of the function.

    Rate this question:

  • 34. 

    Which of the following would allow you to move to the next line:

    • << “Enter \n”;

    • << endl;

    • << Next Line;

    Correct Answer
    A. << endl;
    Explanation
    In C++ programming, the << endl; command is used to insert a newline character, which moves the output to the next line. This effectively ends the current line of text and starts a new one, similar to \n, but endl also flushes the output buffer. 

    Rate this question:

  • 35. 

    What is wrong with the following for loop?       for(int i=0; i<10; i--)       {                   cout << "Hello\n";       }

    • Can not use a for-loop for this

    • I is not initialized

    • Infinite loop

    • Off-by-one error

    Correct Answer
    A. Infinite loop
    Explanation
    The given for loop is an infinite loop because the condition for the loop to continue is i < 10, but inside the loop, the value of i is decremented by i--. This means that i will never be greater than or equal to 10, causing the loop to run indefinitely.

    Rate this question:

  • 36. 

    The break statement:

    • Immediately terminates a program

    • Causes a program to go into an infinite loop

    • Immediately terminates the current block of code

    • Is a special debugging command

    Correct Answer
    A. Immediately terminates the current block of code
    Explanation
    The break statement is used in programming to immediately terminate the current block of code. It is often used in loops or switch statements to exit the loop or skip the remaining code in the block. This allows the program to jump to the next statement after the loop or switch, effectively terminating the current block of code. It does not terminate the entire program or cause an infinite loop.

    Rate this question:

  • 37. 

    Consider the following statement: double alpha[10][5];. The number of components of alpha is _____.

    • 15

    • 50

    • 100

    • 150

    Correct Answer
    A. 50
    Explanation
    The statement "double alpha[10][5];" declares a 2-dimensional array called alpha with 10 rows and 5 columns. The number of components in the array can be calculated by multiplying the number of rows by the number of columns, which is 10 * 5 = 50. Therefore, the correct answer is 50.

    Rate this question:

  • 38. 

    When a void function is called, it is known as

    • An output function.

    • A returned value.

    • An executable statement.

    • A comment

    Correct Answer
    A. An executable statement.
    Explanation
    When a void function is called, it is known as an executable statement because it performs a specific task or action within the program. Unlike functions that return a value, a void function does not provide any output or returned value. Instead, it executes a series of statements or commands to carry out a particular operation. Therefore, calling a void function is considered an executable statement within the program's flow of execution.

    Rate this question:

  • 39. 

    When a void function is called, it is known as

    • An output function.

    • A returned value

    • An executable statement

    • A comment

    Correct Answer
    A. An executable statement
    Explanation
    When a void function is called, it is known as an executable statement because it performs a specific task or action when it is executed. Unlike functions that return a value, void functions do not have a return type and therefore do not return any value. Instead, they are used to perform actions or operations without returning a result.

    Rate this question:

  • 40. 

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

    • 1

    • 2

    • 4

    • 16

    Correct Answer
    A. 4
    Explanation
    The given expression calculates the square root of the result of raising 2 to the power of 4. In other words, it calculates the square root of 16. The square root of 16 is 4.

    Rate this question:

  • 41. 

    (T   F)  A program can still run if it has a warning error.

    • True

    • False

    Correct Answer
    A. True
    Explanation
    A program can still run if it has a warning error because warning errors are not critical and do not prevent the program from executing. Warning errors are typically issued by the compiler or IDE to alert the programmer about potential issues or best practices that should be followed. While it is recommended to address warning errors to ensure the program is optimized and error-free, they do not hinder the program's functionality and execution.

    Rate this question:

  • 42. 

    If x is a char variable, which of the following are legal assignment statements:

    • X = city;

    • X = “city”;

    • X = ‘c’;

    • X = “c”;

    Correct Answer
    A. X = ‘c’;
    Explanation
    The given answer is correct because it assigns the character 'c' to the variable x, which is a char variable. In C++, single quotes are used to represent individual characters, so 'c' is a valid assignment statement for a char variable. The other options are not valid because assigning a string literal or a variable of a different data type to a char variable would result in a type mismatch.

    Rate this question:

  • 43. 

    Which of the following is not part of the Software Life Cycle?

    • Analysis

    • Design

    • Data Entry

    • Implementation

    • Testing

    Correct Answer
    A. Data Entry
    Explanation
    Data Entry is not part of the Software Life Cycle because it refers to the process of inputting data into a computer system, which is not a specific phase or activity in the software development process. The Software Life Cycle typically includes phases such as Analysis, Design, Implementation, and Testing, which are essential steps in developing and deploying software applications. Data Entry, on the other hand, is a separate task that involves entering data into a system, but it is not directly related to the overall software development process.

    Rate this question:

  • 44. 

    Information Hiding is analogous to using

    • An algorithmic design

    • A black-box methodology

    • Actual parameters

    Correct Answer
    A. A black-box methodology
    Explanation
    Information hiding is analogous to using a black-box methodology because both involve the concept of encapsulating details and complexity. In information hiding, the internal workings of a module or object are hidden from the outside world, allowing for easier maintenance and modification. Similarly, in a black-box methodology, the inner workings of a system or process are not visible or accessible, and only the inputs and outputs are considered. Both approaches promote abstraction and modularization, making it easier to understand and work with complex systems.

    Rate this question:

  • 45. 

    Cin >> num; if (num > 0)     num = num + 10; else    if (num >= 5)       num = num + 15; After the execution of the code above, what will be the value of num if the input value is 5?

    • 0

    • 15

    • 25

    • 5

    Correct Answer
    A. 15
    Explanation
    The value of num will be 15 if the input value is 5. This is because the input value is not greater than 0, so the else statement is executed. Since the input value is equal to 5, the condition num >= 5 is true and the value of num is increased by 15. Therefore, the final value of num is 15.

    Rate this question:

  • 46. 

    // will allow you to make a multiple line comment.

    • True

    • False

    Correct Answer
    A. False
    Explanation
    The given correct answer is "False". This is because the statement "// will allow you to make a multiple line comment." is incorrect. In most programming languages, the syntax for making a multiple line comment is different, and using "//" typically indicates a single line comment instead. Therefore, the answer is false as "//" does not allow for multiple line comments.

    Rate this question:

  • 47. 

    (T   F)  A semicolon is always placed after the condition of an if statement.

    • True

    • False

    Correct Answer
    A. False
    Explanation
    A semicolon is not always placed after the condition of an if statement. In most programming languages, including languages like C, C++, Java, and Python, a semicolon is not required after the condition of an if statement. The semicolon is only used to terminate a statement, and the condition of an if statement is not considered a separate statement. Therefore, it is not necessary to include a semicolon after the condition of an if statement.

    Rate this question:

  • 48. 

    What is the value returned by the following function? int function() {       int value = 35;       return value + 5;       value += 10; }

    • 35

    • 40

    • 50

    • 10

    Correct Answer
    A. 40
    Explanation
    The function returns the value of "value" variable plus 5, which is 40. The code after the return statement is not executed, so the line "value += 10;" does not affect the returned value.

    Rate this question:

  • 49. 

    A simplified version of a function which is used to test the main program is called

    • A stub

    • Abstraction

    • Polymorphism

    • A driver

    Correct Answer
    A. A stub
    Explanation
    A simplified version of a function used to test the main program is called a stub. A stub is a placeholder or a temporary implementation of a function that allows the main program to be tested without fully implementing all the functionality. It provides a basic structure or interface for the function, allowing the program to compile and run, but the actual logic or implementation of the function is not fully developed. Stubs are commonly used in software development to simulate the behavior of complex functions or modules during testing.

    Rate this question:

Quiz Review Timeline (Updated): Sep 1, 2024 +

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

  • Current Version
  • Sep 01, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • May 11, 2011
    Quiz Created by
    Tcarteronw
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.