What happens if the inline function is too long or complex?

  • Improved Performance
  • Increased Code Size
  • No Impact
  • Reduced Code Readability
When an inline function is too long or complex, it can lead to increased code size. This is because the function's code is inserted at each call site, potentially resulting in larger compiled code. However, this may be offset by improved performance due to reduced function call overhead.

In C++, if you do not provide a return type for a function, it defaults to ______.

  • auto
  • int
  • nullptr_t
  • void
In C++, when a return type is not explicitly provided for a function, it defaults to 'void.' This means the function does not return a value. It's essential when you have functions that perform actions without returning a result, such as void functions for input/output or setting variables.

Functions in C++ can return multiple values using ______.

  • Pointers
  • References
  • Tuples
  • Arrays
Functions in C++ can return multiple values using tuples. A tuple is an ordered collection of elements, and it's an excellent way to return multiple values from a function. It's more flexible than returning values using pointers, references, or arrays, as it allows you to return values of different types. Tuples were introduced in C++11.

Which C++ keyword can be used to define a user-defined data type?

  • class
  • newtype
  • struct
  • typedef
In C++, the 'typedef' keyword is used to define user-defined data types. It allows you to create aliases for existing data types, making your code more readable and maintainable.

The loop that first checks the condition and then executes its body is called ______.

  • do-while
  • for
  • switch
  • while
The loop that first checks the condition and then executes its body is called a "for loop." In a for loop, you specify the initialization, condition, and increment or decrement all within the loop header. This allows for precise control over loop execution.

For a loop to terminate, the loop condition should eventually evaluate to ______.

  • True
  • False
  • Null
  • Undefined
For a loop to terminate, the loop condition should eventually evaluate to 'False.' If the condition remains 'True,' the loop will continue running indefinitely.

What is the main advantage of using default arguments in C++ functions?

  • They allow for optional function parameters
  • They enforce type safety
  • They improve function performance
  • They reduce code complexity
Default arguments in C++ functions provide the advantage of allowing parameters to have default values. This means that when calling the function, you can choose to omit certain arguments, and the function will use the default values for those omitted arguments. This is especially useful for creating more flexible and user-friendly functions.

Which of the following is a valid overloaded version of the function void display(int a)?

  • int display(int a);
  • void display(char c);
  • void display(float b);
  • void display(int a, int b);
To create an overloaded version of the function void display(int a), you must have a different parameter list. In this case, void display(int a, int b); is a valid overloaded version because it takes two integer parameters instead of just one.

What is the primary difference between a C++ statement and a declaration?

  • Statements and declarations are the same in C++
  • Statements are only used in functions, declarations are used globally
  • Statements define variables, and declarations perform actions
  • Statements perform actions, and declarations define variables
The primary difference between a C++ statement and a declaration is that statements perform actions or operations, while declarations define variables or declare the existence of entities in the program. Statements execute code, while declarations specify the characteristics of variables, functions, or other program elements.

What is the primary purpose of the do-while loop?

  • To create infinite loops
  • To execute code a specific number of times
  • To repeat code until a certain condition is met
  • To skip iterations based on a condition
The primary purpose of the do-while loop in C++ is to repeat a block of code until a certain condition is met. Unlike the while loop, a do-while loop guarantees that the loop body is executed at least once before checking the condition. It's useful when you want to ensure a piece of code runs at least once.