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

Given the following segment of code, draw box diagrams representing all relevant

ID: 3696927 • Letter: G

Question

Given the following segment of code, draw box diagrams representing all relevant variables/data in memory, including simplified addresses for each block of memory. Then, evaluate the code segments that follow (what will be printed to the screen), or write N/A if the line of code will result in a syntax or logic error.

         double numbers[4] = {9.69, 5.73, 21.0, 3.14159};

         char * food = “Nom”;

         int students = 25, professor = 1, * extra = NULL;

________ professor = students + numbers; printf(“%d”, professor);

________ food[0] = ‘n’; printf(“%s”, food);

________ students -= numbers[3]; printf(“%d”, students);

________ extra = &professor; printf(“%d”, extra);

________ *extra = numbers[4]; printf(“%d”, *extra);

Explanation / Answer

1) N/A : assignment makes integer from pointer without a cast

2) N/A : Segmentation fault

3) 21

4) N/A : memory address of processor variable will be printed

5) N/A : Segmentation fault

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote