Hello mcnhscc39,
Although the program does compile there are many problems.
I would start "main" with:
1 2 3 4 5 6
|
int main()
{
constexpr size_t MAXSIZE{ 7 };
string sauce[MAXSIZE] = { "mild", "medium", "hot","sweet", "fruit", "zesty", "verde" };
int sales[MAXSIZE]{ 100, 125, 75, 75, 50, 90, 100 };
|
By initializing "sales" with seven numbers you can comment out the first for loop and concentrate on the rest of the program.
On line 24 should the while condition become true it is an endless loop because the value of "sales[i]" never changes.
For line 32 you have
for (i = 0; i < sizeof(sales) / sizeof(sales[7]); i++)
. This works, but this is much simpler and easier to read
for (i = 0; i < MAXSIZE; i++)
.
Line 37 is OK, but line 38 is totally wrong."i" has a value of 7 which is one past the end of the array. There is no way of knowing what that value is. Its just garbage. I am not sure if you are aware of this, but a seven element array is numbered from zero to six.
Line 38 would work better as a for loop containing the if statement. It would also be better to start the for loop with
for (int i = 0; ...)
. This way when you set "highSeller = i" "highSeller" will have the correct value. The same applies to the part about "lowSeller" although setting "lowSeller" to "sales[0]" may not always work.
When you get to lines 42 and 50 the subscript is likely to be past the end of your array. If this does not give you a run time error it will most likely be pringint garbage.
I will see what I can come up with.
Hope that helps,
Andy