View Single Post
Old 10-07-2004, 04:10 PM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
It is not clear to me what your mean with:
The average is " i/100
That is not an average of anything. Be more specific.
Furthermore, the code below contains a few changes. Also note that I changed floats into doubles. Use doubles as your default precision (in standard c++) unless there is a special reason not to.

Code:
#include <iostream>
#include <cstdlib>

using namespace std;

double squars (int x, double y=0);

int main()
{
  int i(1);
  squars (i);

  cout<< '\n'<< "The average is "<< i/100.0<< '\n';
  
  system("PAUSE");
  return 0;
}

double squars (int x, double y)
{
  while (x<=10)
  {
       y = x * x + y;
     cout<< x*x<< endl;
     x++;
  }
  return y;
}
__________________
Valmont is offline   Reply With Quote