MCQs
Total Questions : 10
Answer: Option B. -> ptr is array of pointer to function.
In this expression, ptr is array not pointer.
Answer: Option C. -> functions
None.
Answer: Option D. -> compile time error
In this program, we can’t do the casting from char to int, So it is raising an error.
Answer: Option C. -> data types
The data types are mandatory for declaring the variables in the function pointers.
Answer: Option A. -> d9 9
None.
Output:
$ g++ pfu1.cpp
$ a.out
d9
9
Answer: Option D. -> 22
As we are calling the function two times with the same value, So it is printing as 22.
Output:
$ g++ pfu.cpp
$ a.out
22
Question 7.
1.
#include
2.
using namespace std;
3.
int add(int first, int second)
4.
{
5.
return first + second + 15;
6.
}
7.
int operation(int first, int second, int
(*functocall)(int, int))
8.
{
9.
return (*functocall)(first, second);
10.
}
11.
int main()
12.
{
13.
int a;
14.
int (*plus)(int, int) = add;
15.
a = operation(15, 10, plus);
16.
cout
What is te output of this program?
1.
#include
2.
using namespace std;
3.
int add(int first, int second)
4.
{
5.
return first + second + 15;
6.
}
7.
int operation(int first, int second, int
(*functocall)(int, int))
8.
{
9.
return (*functocall)(first, second);
10.
}
11.
int main()
12.
{
13.
int a;
14.
int (*plus)(int, int) = add;
15.
a = operation(15, 10, plus);
16.
cout
Answer: Option C. -> 40
In this program, we are adding two numbers with 15, So we got the output as 40.
Output:
$ g++ pfu2.cpp
$ a.out
40
Answer: Option C. -> both a & b
As it is used to execute a block of code, So we will not allocate or deallocate memory.
Answer: Option A. -> __cdecl
None.
Answer: Option C. -> function
None.