title: C++ ( using file data to make calculation through functions)
body: <p>how to use the file after reading it in a function,and make the calculation in another function ?</p>
  
  <p>here is the code that i was trying to make ..</p>
  
  <pre><code>void readFile(ifstream&amp;); //file reading 
  
  void DisplayAdd(ifstream&amp; somefile);  //here what i don't understand do i use void or int !  
  //and how is it going to use the data from the file !!
  
  
  int main()
  {
  ifstream inputfile;
  inputfile.open("numbers.txt");
  readFile(inputfile);         //calling function to make reading file
  DisplayAdd(inputfile);      //calling function to make addition
  }
  inputfile.close(); //closing file
  return 0;
  }
  
  void readFile(ifstream&amp; somefile) //reading data from file ..
  {
  double num1,num2,num3,num4,num5;
  while(somefile&gt;&gt;num1&gt;&gt;num2&gt;&gt;num3&gt;&gt;num4&gt;&gt;num5)
      cout&lt;&lt;num1&lt;&lt;endl&lt;&lt;num2&lt;&lt;endl&lt;&lt;num3&lt;&lt;endl&lt;&lt;num4&lt;&lt;endl&lt;&lt;num5&lt;&lt;endl;
  }
  
  void DisplayAdd(ifstream&amp; somefile) //how to make the calculation here is it like this !
  {cout&lt;&lt;num1+num2+num3+num4+num5;
  }
  </code></pre>