Macro vs FunctionComputer Science Level 4
C/C++ code snippet 1 (macro):
C/C++ code snippet 2 (function):
1 2 3 4
An integer array of 5 elements is declared and initialized in
The macro and function of the code snippets above are declared and defined globally.
main(), the macro and the function are called with the argument
arr as follows,
What's the absolute difference between the values stored in
f, i.e., what's the value of \(|m-f|\) ?
Details and Assumptions:
sizeof()is an inbuilt C/C++ function which returns the number of bytes occupied by an object.
main()is the function block which is called first when the code is compiled and executed.
Assume that the code is being executed in a 32-bit compiler on a 32-bit machine, which means that an
int*variable takes 4 bytes of memory, i.e., we have