# C/ObjC Block Quizzes

Apple introduced blocks (anonymous functions or lambdas) as C extensions for its parallel programming model Grand Central Dispatch. Unlike ordinary C functions, blocks can capture surrounding variable contexts. The captured variables are casts to const by default, and for mutable variables you can mark it with __block storage qualifier. However, there is a lot of pitfalls in __block variables. Can you identify all of them?

## Testing environment

The above is compile configuration and the program structure of the quiz. You can download and test the code form Github.

## Quiz 1

What would be printed if we execute quiz_1() then boringBlock()? Would &x be printed in same address or different addresses?

## Quiz 2

Now, if we change the variable x in quiz_2() scope, would captured variable x also changes its value?

## Quiz 3

Would x and *ptr be the same value?

## Quiz 5

Block execution:

What if we copied the block twice. Would the address change twice also?