Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 2 - Process Memory The purpose of this part is to explore the memory associated with the user process: text, data, and stack. Compile

Part 2- Process Memory
The purpose of this part is to explore the memory associated with the user process: text, data, and stack.
Compile and run the program: memory_segments.c.
Several addresses are output from the program including:
etext
edata
end
functions
global variables
static local variables
heap variables
Your task is to fill in addresses of the variables, and functions in lab1.c.
You will change the addresses to match what you are seeing when you run memory_segments.c.
Please remember to include the "etext", "edata", and "end" addresses
As variables are added to the stack, do the addresses get smaller or larger?
Do variables stored on the stack ever have the same address as other variables? Why or why not?
Where would you expect variables (or arguments) in recursive functions to be stored (stack, heap, or other data segment)? When you are finished step 6 below, comment on whether your expectations were correct or not.
Test your expectation by creating a recursive factorial function in lab1.c . For instance, the factorial of 5 is represented by 5! and is calculated as 5x4x3x2x1=120.
In the factorial function, you will print the address of the factorial function and the address of the argument passed to it.
In main, you will prompt the user for what factorial they will want to calculate and send that input as an argument to the function. In main, you will also print the value returned from the factorial function.
Note: you will be expected to use scanf and printf
The idea behind the recursive factorial function is the following:
Fn ={
1 if n =0(base case)
n*Fn-1 if n >=1(recursive step)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

Illustrate the value of different types of employment tests.

Answered: 1 week ago