Question: C program This is a study guide for an exam. Answers along with explanations would be extremely helpful. Thanks. Using the code below apply the

C program

This is a study guide for an exam. Answers along with explanations would be extremely helpful. Thanks.

Using the code below apply the following assumptions: The address of num1 is 2000, of num2 is 3000, of num3 is 4000 of pr1 is 5000 of pr2 is 6000 of pr3 is 7000.

a. #include

b. int main (void)

c. {

d. int num1=123, num2=234, num3=345;

e. int *pr1, *pr2, **pr3;

f. pr2 = &num1;

g. pr1 = &num3;

h. pr3 = &pr2;

j. printf(" Value here is: %d", *pr2);

k. printf(" Value here is: %p", pr3);

m. printf(" Value here is: %p", *pr3);

n. printf(" Value here is: %d", **pr3);

o. printf(" Value here is: %p", &pr1);

p. *pr3 = &num2;

q. printf(" Value here is: %d", *pr2);

r. printf(" Value here is: %p", pr3);

s. return 0;

t. }

List the output for the printf() statements in this program in the order they appear.

Using the code below apply the following assumptions: size of an int is 2 bytes, size of a char is 1 byte, size of a float is 4 bytes. IGNORE COMPILE ERRORS.

a. #include

b. #include

c. int main( void ) {

d. int nelem = 8, i, index;

e. char *arrPtr, *itemPtr;

f. arrPtr = malloc(nelem * sizeof(char));

g. printf("arrPtr = %p, size of char = %lu ", arrPtr,

h. sizeof(char));

g. for ( i = 0; i < nelem; i++) {

h. itemPtr = arrPtr + i;

j printf("Storing char at memory location = %p (index = %i) ", itemPtr, i);

k. *itemPtr = 'x';

m. }

n. printf(%c, *itemPtr);

n. return 0;

p. }

2. How many bytes of space will be set aside by the malloc() on line f?

3. What will the printf() on line n display?

4. T / F There is a memory leak in this program.

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 Databases Questions!