Question: Here is hw 8 . c #include #include int g 0 ; / * global variable, uninitialized * / int g 1 = 1 4

Here is hw8.c
#include
#include
int g0; /* global variable, uninitialized */
int g1=14; /* global variable, initialized */
int g2[1500]; /* global variable, uninitialized */
int g3=16; /* global variable, initialized */
int g4; /* global variable, uninitialized */
void proc1();
void proc2();
int main()
{
extern int etext[], edata[], end[];
int lc0; /* local variable, stored on stack */
int lc1=27; /* local variable, stored on stack; mix init and uninit */
int lc2; /* local variable, stored on stack */
static int ls0; /* local static variable, uninitialized data */
static int ls1=19; /* local static variable, initialized data */
int *pheap1;
int *pheap2;
pheap1=(int *) malloc(1000* sizeof(int));
pheap2=(int *) malloc(1000* sizeof(int));
printf("
---------- main -------------------
");
printf("%14p (%15lu): Last address
",
0xffffffffffff,999999999999999);
printf("%14p (%15lu): Address etext
",
etext, etext);
printf("%14p (%15lu): Address edata
",
edata, edata);
printf("%14p (%15lu): Address end
",
end, end);
printf("%14p (%15lu): Address of code for proc1
",
&proc1, &proc1);
printf("%14p (%15lu): Address of code for proc2
",
&proc2, &proc2);
printf("%14p (%15lu): Address of uninitialized global variable g0
",
&g0, &g0);
printf("%14p (%15lu): Address of initialized global variable g1
",
&g1, &g1);
printf("%14p (%15lu): Address of uninitialized global array g2
",
&g2[0], &g2[0]);
printf("%14p (%15lu): Address of initialized global variable g3
",
&g3, &g3);
printf("%14p (%15lu): Address of uninitialized global variable g4
",
&g4, &g4);
printf("%14p (%15lu): Address heap1 in heap space
",
pheap1,(unsigned long) pheap1);
printf("%14p (%15lu): Address heap2 in heap space
",
pheap2,(unsigned long) pheap2);
printf("%14p (%15lu): Address of local variable lc0
",
&lc0, &lc0);
printf("%14p (%15lu): Address of local variable lc1
",
&lc1, &lc1);
printf("%14p (%15lu): Address of local variable lc2
",
&lc2, &lc2);
printf("%14p (%15lu): Address of local uninitialized static var ls0
",
&ls0, &ls0);
printf("%14p (%15lu): Address of local initialized static var ls1
",
&ls1, &ls1);
proc1();
proc2();
return 0;
}
void proc1(){
int lc3;
int lc4=37;
printf("
----------- proc1------------------
");
printf("%14p (%15lu): Address of code for proc1
",
&proc1, &proc1);
printf("%14p (%15lu): Address of global variable g0
",
&g0, &g0);
printf("%14p (%15lu): Address of global variable g1
",
&g1, &g1);
printf("%14p (%15lu): Address of global variable g2
",
&g2[0], &g2[0]);
printf("%14p (%15lu): Address of global variable g3
",
&g3, &g3);
printf("%14p (%15lu): Address of global variable g4
",
&g4, &g4);
printf("%14p (%15lu): Address of local variable lc3
",
&lc3, &lc3);
printf("%14p (%15lu): Address of local variable lc4
",
&lc4, &lc4);
}
void proc2(){
int lc5;
int lc6=51;
static int ls2;
static int ls3=47;
printf("
------------ proc2-----------------
");
printf("%14p (%15lu): Address of code for proc2
",
&proc2, &proc2);
printf("%14p (%15lu): Address of global variable g0
",
&g0, &g0);
printf("%14p (%15lu): Address of global variable g1
",
&g1, &g1);
printf("%14p (%15lu): Address of global variable g2
",
&g2[0], &g2[0]);
printf("%14p (%15lu): Address of global variable g3
",
&g3, &g3);
printf("%14p (%15lu): Address of global variable g4
",
&g4, &g4);
printf("%14p (%15lu): Address of local variable lc5
",
&lc5, &lc5);
printf("%14p (%15lu): Address of local variable lc6
",
&lc6, &lc6);
printf("%14p (%15lu): Address of local uninitialized static var ls2
",
&ls2, &ls2);
printf("%14p (%15lu): Address of local initialized static var ls3
",
&ls3, &ls3);
}
Part 1:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!