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

Questions : Options : A. Register B. Stack C. Heap D. Data Segment E. Text Segme

ID: 3876175 • Letter: Q

Question

Questions:

Options:
A. Register
B. Stack
C. Heap
D. Data Segment
E. Text Segment

  Where does the memory referenced by primes[] reside in the process virtual address space?  
  Where does the memory referenced by result reside in the process virtual address space?  
  Where does the memory pointed to by the pointer p reside in the process virtual address space?  
  Where does the memory address stored in the pointer p reside in the process virtual address space?  
  Where does the memory referenced by val reside in the process virtual address space?  

Options:
A. Register
B. Stack
C. Heap
D. Data Segment
E. Text Segment

       
QUESTION 1 Consider the following simple program: #include char qlobBuf [ 655351 int primes[] = { 2, 3, 5, 7); static int square(int x) int result result = x * x; return result; static void doCalc (int val) printf("The square of %d is %d ", val, square(val)); if (val

Explanation / Answer

a.) primes[] will be stored in Data memory as it is initialized globally.

b.) Since variables inside a method are local. Therefore, result will store in stack.

c.) pointer p stores at stack.

d.) However, memory pointed by pointer p is in heap.

e.) Since key is initialized as static, therefore it is stored in Data memory.