Hi, i am currently doing a final assignment for my programming module at college and i am struggling to get the correct output for one part of the program and the lecturer is unable to help us with it. Our class had just started looking at arrays when we were given the assignment
the overall program works with 4 modules but the section of code i am stuck with uses only 2 of the modules but it could probably get by with just the 1 as i had created the 2nd to help with another loop.
the problem I am having is the array either multiplies the total of each array, which is around 5x bigger then it should be, add the total of arrays together or come up with a completely different answer when ever i try a different combination with the part of the code. The program that i have used to create it is BCC55 by Borland.
below is the section of code that isn’t working along with the modules that are used in the code
to help i have made a table that has all the correct outputs for the program in. so i know which are the correct and incorrect outputs
the correct out put is for the iTotalFound is 3087, while the correct output for the iValue is supposed to be 2,115,550
incorrect outputs for iValue include 687293 and 10869327.
i also have an idea to ry and fix it but i don’t know how to implement it. The solution I have is to use a previous section of code to create an add loop for the array til until the counter hits 6 when it will stop adding to the iValue. I have worked out that I will probably need the following line of code with some value in the array part:
iValue = iValue + (iTotalFound * iArray2[ ])
below is the code from a previous loop that is working correctly. It include the choice selection and cout code: