Input File Stream

  1. There are 100 lines in "/home/solomon/data.txt". There is exact one integer in a line.
  2. Write a program and use the "ifstream" class to read data from this file. Calculate the sum and average of these numbers.
  3. In case we cannot predict the length of the data file in advance, your program must be flexbile to handle files with arbitrary number of lines.
    
    while (fsIn >> n)
        {
            sum += n;
            count++;
        }