Functions Questions
Practice Functions MCQs with answers and explanations. Page 1 of 5.
Category
C++ Programming
Topic
Functions
Page
1 / 5
Mode
Practice
Questions
Open any question to view the answer and explanation.
C++ default arguments: which statement below is incorrect regarding default function arguments?
Open
View answer
C++ default arguments: which statement is correct about redefinition and using function calls as defaults?
Open
View answer
C++ default parameters: identify which declarations are invalid and choose the best summary.
Open
View answer
C++ default arguments usage: in what effective order do omitted arguments get supplied at the call site?
Open
View answer
C++ overloading limits: which of the following functions cannot be overloaded? (Choose the only correct option.)
Open
View answer
C++ function overloading: which statement about parameter counts and types is correct?
Open
View answer
In C++ default-argument rules, which of the following statements is incorrect?
Read carefully and select the option that violates how default parameters work in real code.
Open
View answer
Default parameters in C++: which statement is correct about how many parameters may be defaulted?
Choose the rule that best reflects the language design.
Open
View answer
Function overloading: which statement is correct under standard C++ rules?
Assume normal overload resolution; default arguments do not change a function’s signature.
Open
View answer
If a function has three parameters, which position(s) may legally have default arguments under standard C++ rules?
Choose the most accurate statement.
Open
View answer
Which statement is correct about constructors and default parameters in C++?
Pick the option that matches the language capabilities.
Open
View answer
Const-correctness for function parameters in C++: which statement is correct?
Focus on what it means to accept constants and the restrictions on modification.
Open
View answer
Default arguments: which statement is incorrect with respect to declaration and usage sites?
Pick the option that violates best practice or standard rules.
Open
View answer
Overloading with default arguments: which statement is correct under C++ rules?
Assume you avoid ambiguity by careful design.
Open
View answer
Where should the default value of a function parameter be specified in C++?
Choose the place(s) allowed by the language (avoid duplicating across declarations).
Open
View answer
Which of the following function prototypes is perfectly acceptable in C++ for using a default argument?
Assume referenced names are declared before the prototype.
Open
View answer
C++ default parameters: which function(s) cannot legally have default arguments?
Open
View answer
In C programming (assume sizeof(int) = 2 bytes), what will this program print?
#include <stdio.h>
void fun(char**);
int main()
{
char argv[] = {"ab", "cd", "ef", "gh"};
fun(argv);
return 0;
}
void fun(char p)
{
char t;
t = (p += sizeof(int))[-1];
printf("%s
", t);
}
Carefully analyze the pointer arithmetic on the char parameter and identify the string printed.
Open
View answer
In C, what will this program print? Focus on the comma operator used in the return expression.
#include<stdio.h>
int addmult(int ii, int jj)
{
int kk, ll;
kk = ii + jj;
ll = ii * jj;
return (kk, ll);
}
int main()
{
int i=3, j=4, k, l;
k = addmult(i, j);
l = addmult(i, j);
printf("%d, %d
", k, l);
return 0;
}
Open
View answer
In C, predict the output and trace scope and parameter shadowing carefully.
#include<stdio.h>
int i;
int fun1(int);
int fun2(int);
int main()
{
extern int j;
int i=3;
fun1(i);
printf("%d,", i);
fun2(i);
printf("%d", i);
return 0;
}
int fun1(int j)
{
printf("%d,", ++j);
return 0;
}
int fun2(int i)
{
printf("%d,", ++i);
return 0;
}
int j=1;
Open
View answer
Practice smarter
Solve a few questions daily and revisit weak topics regularly to improve accuracy.