wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C++ Lambda Expression

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

What is lambda expression?

a)

an anonymous function which could be written inline

b)

group of statements that is given a name, and which can be called from some point of the program

c)

a variable that stores the address of a function that can later be called through that variable

d)

objects that can be treated as though they are a function or function pointer

2.

int FooBar(int foo, double bar) { ... }


this is the declaration of...

a)

function

b)

function pointer

c)

function object

d)

lambda expression

3.

int ( *awesome )(const char *, bool) = nullptr;


this is a declaration of...

a)

function pointer

b)

function

c)

function object

d)

lambda expression

4.

This code snippet is an example of...

a)

functor

b)

function pointer

c)

lambda expression

d)

function

5.

[](){}();


this is an example of ...

a)

lambda expression

b)

function

c)

functor

d)

function pointer

6.

[]{};


What is wrong with that code.

a)

Nothing is wrong

b)

Compile Error

c)

Runtime Error

d)

Exception Thrown

7.

[]{ cout << "Hello!"; };


What is the output shown in console...

a)

(no output)

b)

Hello!

c)

"Hello"

d)

Compile error!

8.

[]{ cout << "Hello!"; }( );


What is the output shown in console...

a)

(no output)

b)

Hello!

c)

"Hello"

d)

Compile error!

9.

what is hi?

a)

void (*hi)()

b)

int hi

c)

void hi

d)

void *hi

e)

void hi()

10.

What is the output?

a)

Hello, scope!

Hello, lambda! 2

b)

Hello, world!

c)

Hello, scope!

Hello, lambda 1!

Hello, lambda! 2

d)

Hello, scope!

Hello, lambda 1!

e)

Hello, lambda! 2

11.

[ ]


what does that lambda capture mean?

a)

it's not capturing any variable from outside

b)

it's capturing all variables from outside

c)

it's capturing all variables from outside but Read Only

d)

it's capturing all variables from outside both Read and Write

12.

[=, &x]


What does that lambda capture mean?

a)

Accepting all outside vars Read Only, but x is Read and Write

b)

Accepting all outside vars Read Write, but x is Read Only

c)

Accepting only x which is Read Only.

d)

Accepting only x which is Read/Write

13.

What is the output of line 13?

a)

50 20 30

b)

10 24 77

c)

10 20 30

d)

50 24 77

14.

What is the problem with that code?

a)

i is read only, could not assign any value to i

b)

nothing is wrong

c)

invalid capture

d)

it's not proper lambda function

e)

the function never been called

15.

what is the output?

a)

26

b)

13

c)

42

d)

60

16.

Which is the INCORRECT statement of lambda?

a)

Improve reusability

b)

Anonymous

c)

Compact

d)

Improve locality

17.

Which is the CORRECT capture?

a)

[&x = i, y = j + 4, k = 77]

b)

[&, x, &y]

c)

[=, &x, y]

d)

[x, &x]

18.

hi is ...

a)

function pointer

b)

function

c)

functor

d)

lambda expression

19.

hello is ...

a)

function

b)

functor

c)

function pointer

d)

lambda expression

20.

What is the output?

a)

Hello, oppa!

Farewell, oppa!

b)

Hello, oppa!

c)

Farewell, oppa!

d)

Error!