Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the code for a simple C program with the following features (the exact det

ID: 640424 • Letter: W

Question

Write the code for a simple C program with the following features (the exact details are completely upto you): (i) main() calls a function foo() which in turn calls a function bar(), (ii) has a global variable int *a, and (iii) bar() dynamically allocates an integer and assigns its address to a. On a time-line, show the contents of the process address space: (a) just before the dynamic memory allocation in bar(), (b) just after the dynamic memory allocation in bar(), and (c) just after bar() returns. Be sure to identify specific contents within the frames of the process stack

Explanation / Answer

#include<stdio.h>

void foo()

{

int a;

int bar=bar(int);

printf(