cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Incorrect Average
Incorrect Average
Jul 22, 2018 at 7:11pm UTC
addonexus
(5)
I am supposed to get numbers from an input file and display the average. The problem is I keep getting 0 as my average and that's incorrect.
Last edited on
Jul 22, 2018 at 11:33pm UTC
Jul 22, 2018 at 7:57pm UTC
Ganado
(6812)
Nowhere do you increment counter, or call calcAvg().
Jul 22, 2018 at 8:18pm UTC
H00G0
(492)
As Ganado said:
*You need to increment
counter
in your
readFile
function, inside the while loop.
*You need to call
calcAvg
in your main function after
readFile
and before
closeFile
Jul 22, 2018 at 9:16pm UTC
addonexus
(5)
however, I don't understand exactly what you mean by calling it in my main function, I thought I had already called it here:
Last edited on
Jul 22, 2018 at 11:34pm UTC
Jul 22, 2018 at 9:20pm UTC
Ganado
(6812)
You
defined
it there.
You should read the function tutorial:
http://www.cplusplus.com/doc/tutorial/functions/
Topic archived. No new replies allowed.