The data type used for storing raw memory addresses is ______.

  • address_t
  • char
  • intptr_t
  • pointer
The data type used for storing raw memory addresses is intptr_t, which is an integer type designed to hold a memory address. It ensures that memory addresses are correctly represented, allowing you to work with pointers and addresses in a portable way.

Global variables, when declared outside all functions, have ______ storage duration by default.

  • auto
  • extern
  • static
  • volatile
When global variables are declared outside all functions, they have static storage duration by default. Static storage duration means they exist for the entire program's lifetime.

Lisa wants to check the day of the week and execute different code for each day. Which control structure would be the most appropriate for her use?

  • For Loop
  • If-Else Statements
  • Switch Statement
  • While Loop
For Lisa's scenario, the most appropriate control structure is the "Switch Statement." A switch statement allows you to evaluate a single expression against multiple possible constant values, making it ideal for executing different code blocks based on the day of the week.

In C++, which operator is right-to-left associative?

  • Addition Operator (+)
  • Assignment Operator (=)
  • Multiplication Operator (*)
  • Ternary Conditional Operator (?)
The ternary conditional operator (a ? b : c) in C++ is right-to-left associative. This means that it evaluates from right to left, making it different from most other operators in the language.

Chris has a complex expression with multiple operators. He is unsure about the order of operations. Which principle should he revisit to clarify the order?

  • BODMAS
  • FIFO
  • LIFO
  • PEMDAS
Chris should revisit the PEMDAS principle, which stands for Parentheses, Exponents, Multiplication and Division (from left to right), and Addition and Subtraction (from left to right). It helps clarify the order of operations in complex mathematical expressions.

The action of executing a function within a program is called function ______.

  • Prototype
  • Declaration
  • Definition
  • Invocation
The action of executing a function within a program is called "Invocation." When you invoke a function, you are instructing the program to execute the code inside that function. The other options have different meanings: Prototype is a declaration of the function's signature, Declaration is a statement that tells the compiler about a function's name and signature, and Definition is the specification of a function's behavior.

What is the impact on performance when using nested loops extensively?

  • Degrades Performance
  • Improved Performance
  • No Impact on Performance
  • Performance Depends on Loop Type
Extensively using nested loops can significantly degrade performance. Each additional level of nesting increases the number of iterations exponentially, which can lead to slower code execution and increased resource usage. It's essential to carefully consider the need for nested loops in your code.

Given the expression a = b + c * d, which operation will be performed first?

  • Addition (+)
  • Assignment (=)
  • Multiplication (*)
  • Variable Retrieval (a, b, c, d)
In most programming languages, including C++, multiplication (*) takes precedence over addition (+). So, in the given expression, c * d will be performed first.

When you provide the necessary details about a function without its actual implementation, it's called function ______.

  • Declaration
  • Invocation
  • Definition
  • Execution
When you provide the necessary details about a function without its actual implementation, it's called "Definition." In a function definition, you specify the function's name, return type, parameter list, and what the function should do when called. The other options have different meanings: Declaration is a statement that tells the compiler about a function's name and signature, Invocation is the act of calling a function, and Execution is the process of running the function's code.

In C++, the ______ keyword is used to specify a block of code that should be executed no matter whether an if condition is true or false.

  • Catch
  • Do
  • Else
  • Finally
In C++ and many other programming languages, the "else" keyword is used to specify a block of code that should be executed when the condition in an "if" statement is false. It's commonly used to provide an alternative action when the condition isn't met.

When using a switch statement, if a case doesn't contain a break, it will cause a behavior known as ______.

  • exception
  • fall-through
  • overflow
  • recursion
In C++, when a case within a switch statement doesn't contain a break statement, it leads to fall-through behavior. This means that execution will continue from the matched case statement to the subsequent case(s) until a break is encountered or the switch block ends. It's a powerful feature for handling multiple cases with the same code, but it should be used intentionally.

If you have multiple conditions, which statement can be used to test multiple conditions sequentially?

  • do-while loop
  • for loop
  • if-else statement
  • switch statement
The 'if-else' statement in C++ is used when you have multiple conditions to test sequentially. It allows you to define different blocks of code to execute for different conditions, providing a structured way to handle multiple possibilities.