Question: Q1. (a) Explain what is meant by dynamic memory allocation. Why is this useful? Given that a C program contains an integer variable called n,
Q1. (a) Explain what is meant by dynamic memory allocation. Why is this useful? Given that a C program contains an integer variable called n, write a piece of C code which will dynamically allocate memory for an array called vec consisting of n elements of type int. (30%) (b) Explain what is meant by a preprocessor directive in C. What is the effect of the macro ide fine LINFUNC(x) How does the use of the macro LINFUNC (x) in a C program differ from the use of the function linfunc with definition int linfunc(int x) return (7x 1) (35%) (c) Explain clearly the operation of the following C program, detailing the effect of each line of the program. #include int main (void) int x[61 int *ptr: for (i-0;i5;i++)>
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
