I think you may have read the question wrong. In the question, it asks what is the most that Bessie is over the speed limit. You have calculated how many times Bessie is over the speed limit. Also, you have 2 nested for loops in your solution. You have to change the control variable in the nested one, otherwise, the i's in the outer for loop will keep changing to the wrong values.
A nested for loop is a for loop inside of another for loop. If you didn’t know, you can change the value of the control variable of a for loop inside of the for loop. Since the outer for loop has a control variable i and since you are changing that variable inside of the inner for loop, the value of i will change. And in your case, i is increasing in the inner for loop. Change that variable name to j(as tradition often dictates) or any variable name you like.
A segmentation fault is when you try to access some memory that is not allocated for your code. This usually happens when you try to access an index that is outside of an array or vector.
Edit,
This is not how you did it.
Edit,
Another way to get a segmentation fault is when a statically sized array does not know how much memory to allocate. This is how you did it. Look at the code above.
Basically, but there are other ways. The index that is outside of your array is how you did it.
Edit,
I am wrong. You did it another way. I have to change my answer. I am so sorry.
You actually did it another way. Another way you can get a segmentation fault is when a statically sized array does not know how much memory to allocate.