Will Lesher
02/21/23
CPSC 1011, Section 004
Lab #5
Using an editor, answer the following questions:

NAME: Will Lesher

---------
example.c
---------
1) What is the cause of the seg fault in the program called example.c?
- The cause of the seg fault is in the for loop on line 10. I is initialized to 0 which works but then in the condition i is set as greater than or equal to 0. With i being initialized as 0 the loop wouldn't work properly. For this code to run properly the condition would need to be changed. You would need to change the condition from i >= 0 to i <= 5. 

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

3) What was the value of the variable "count" at the time of the seg fault?
- The value of the variable "count" is 10. 

4) What was the value of the variable "i" at the time of the seg fault?
- The value of the variable "i" is 409.

5) What was the value of the variable "search" at the time of the seg fault?
- The value of the variable "search is 1.

6) What are the values in the "table" array?
- The values in the table array are 5, 10, 12, 14, 16, 18, 20, 22, 24, 26.

7) what do you think the bug is?
- The bug was on line 27 in the while loop. What was previously there was "search = 1. This is an invalid statement and it had to be changed. I changed this to "search == 1" and the program ran properly. In C a single = sign is a assignmentoperator while == is a comparison operator. Since we were trying to see if search equals 1 we want to use ==, a single = would just set search as now equal to 1. 


