Can anyone give me some kind of hint of what I am doing wrong here?

I am trying to find the median integer in the file. I have set it up the way my teacher asked us to, which was to make 2 passes through the file entitled "Section51.dat". The first pass (loop) is supposed to figure out how many numbers are in the file. This works correctly.

But the second loop is supposed to get the number in the middle of the file. For me it is just dividing the count in half which means I am obviously not doing something correct.

I also can't figure out how to do this in a case when you have an even set of integers in "Section51.dat" because then you will obviously need to average the two numbers in the middle of the file to get the median.

I have not had very much experience (or luck) with while loops yet, and I can't figure out how I am supposed to get the median integer. Can someone give me some guidance?

Code:#include <iostream> #include <fstream> using namespace std; int main() { ifstream WOW; WOW.open("Section51.dat"); int count = 0, aNumber; while (WOW >> aNumber) { count++; } int median; if (count / 2.0 == 0) { median = (count / 2.0) + ((count / 2.0) + 1) / 2.0; } else { median = count / 2.0; } while (WOW >> aNumber && count << median) { count++; median--; } cout << aNumber; return 0; }