C language

Q4: Memory Allocation

What is the output of the following code? (a) 3              (b) 5       (c) Can’t say Ans: Many would answer it as 3 but it is wrong. The way we have tried to do it is wrong. As we enter into main we have a memory allocated for variable x and then function abc is called. Now […]

C language

Q3: Memory allocation

Consider the C code Explain the allocation of memory in stack for the above program. Ans: firstly a frame in stack is created and memory is allocated to store variable x with value 3. And then function call is made to function fun() and a new frame is created in the stack. Firstly return address to […]

C language

Q2: Memory Allocation

Consider the C code: Now we have to picturize the whole scenario in HEAP and STACK memory. Ans: We have no dynamically allocated variables in this program. Hence there is not much role of HEAP memory. We analyze the memory allocation and de-allocation in STACK on next page. We know stack memory is used to […]

C language

NULL pointer

It is the simplest pointer. The NULL pointer is a pointer which points to no where.. We can also use integer 0 in place of constant NULL. Int* x=NULL; The above statement creates a NULL pointer x. DEREFERENCING NULL As we know NULL pointer is actually a pointer which points to nowhere and hence we […]