Lab 5, Spring 2023

Using an editor, answer the following questions:

NAME: Colt Cavaleri

---------
example.c
---------
1) What is the cause of the seg fault in the program called example.c?

The cause of the seg fault in example.c is the code in lines 10 and 11. Line 11 contains the code "for (i = 0; >=0; i++) {". 
This causes a problem when combined with the next line, "sum += data[i];". Line 10 will continuously increment the value of i as long as it is greater than or equal to 0, while line 11 will continuously add the value of data[i] to sum.
This means the array will infinitely expand beyond its defined bounds, causing the segfault.


--------
broken.c
--------
2) What line in broken.c did the program seg fault on?

Broken.c segfaults on line 28.

3) What was the value of the variable "count" at the time of the seg fault?

The value of count at the time of the seg fault is 10.

4) What was the value of the variable "i" at the time of the seg fault?

The value of i at the time of the seg fault is 425.

5) What was the value of the variable "search" at the time of the seg fault?

The value of search at the time of the seg fault is 1.

6) What are the values in the "table" array?

The values in the array are
table = {5, 10, 12, 14, 16, 18, 20, 22, 24, 26}

7) what do you think the bug is?

I'm not entirely sure what the problem was but I fixed it when I changed search = 1 to search = 0 in line 27.
