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

There are 5(9-13) mini questions. Please take time to double check your work. Th

ID: 3886078 • Letter: T

Question

There are 5(9-13) mini questions. Please take time to double check your work. Thank you

This and the following questions provide code and you have to answer whether or not there is a bug in that code If yes, give the number of the line where the bug is If there are bugs in more than one line or the code is wrong because of a combination of lines, list all these line numbers in increasing order, separated with a comma and with no extra spaces (e.g. 1 If the code is wrong because there is a memory leak (allocated memory was not freed) answer with the word leak If the code is correct (no bug), answer with the word none Example of correct answer formats: 1,5,6,7 one leak Examples of incorrect answer formats 5,6,7,1 (not in increasing order) 1567 (separated by spaces, not by commas) intmem 1 in(änt x) line 1 / line 2 / line 3 return x; void mem_1) i // line 4 // line 5 int x = 10; int * = mem 1 in (x) ; printf("+p = %d ". *p); // line 6 Iine // 7 QUESTION 10 / Allocate dynamic memory, set it to 25, return the pointer to it. int mem 31 line1 // line 2 int *p = 25; print f("p=ed " , return Pi //line 3 +P ); // line 4 Give the line(s) with bugs or none

Explanation / Answer

Question 9:

Answer: none

Explanation: The given code is correct and produces proper output ,and here the output would be 12.

Question 10:

Answer: 2,3

Explanation: The given code is incorrect and produces segmentation fault. Statement of line 2 defines a pointer which is pointed to address 25 in memory, it compiles because there's no syntax error. The content of p is the address 25, and it doesn't have an internal memory to store a value because no memory allocation is done. So when we tried to print the content of p by line 3 segmentation fault occurs!

Question 11:

Answer: none

Explanation: The given code is correct and compiles without error and manipulates local variable correctly.

Question 12:

Answer: 4

Explanation: The given code is incorrect and produces segmentation fault. Statement of line 2 defines a pointer, Line 3 allocates a memory for an integer pointed by p. But the content of p is set to 7 which is treated as memory address at line 4. It compiles because there's no syntax error. The content of p is the address 7, and it doesn't set to any integer value for store. So segmentation fault occurs!

Question 13:

Answer: none

Explanation: The given code snippet is correct and compiles without error.

/*If this helps you, please let me know by giving a positive thumbs up. In case you have any queries, do let me know. I will revert back to you. Thank you!!*/