Hi Guys,

Tried to take on the points everyone has passed onto me and have come up with the following that:

I Been asked to create a SIMPLE program with an array that holds values from 0 - 100. I then need to write functions to calculate:

- largest number in the array

- smallest number in the array

- the sum of all of the numbers in the array

- the mean of all of the numbers in the array

So I created a file called values.h that I want to calculate (get) and show (display) the values on screen:

Code:

// values.h
// Determining the largest, smallest, sum and mean
# include <iomanip>
//# include <iostream.h>
//# include <iomanip.h>
class values
{
public:
int get_largest_number();
int get_smallest_number();
int get_sum_of_number();
int get_mean_of_number();
void display_largest_number() ;
void display_smallest_number() ;
void display_sum_of_number() ;
void display_mean_of_number();
protected:
int largest_number;
int smallest_number;
};
int values::get_largest_number(int a[])
{
largest_number = a[0];
for(i=1; i<20; i++)
{
if(a[i] > largest_number)
{
largest_number = a[i];
}
}
}
int values::get_smallest_number(int a[])
{
smallest_number = a[0];
for(i=1; i<20; i++)
{
if(a[i] < smallest_number)
{
smallest_number = a[i];
}
}
}
int values::get_sum_of_number(int a[])
{
int avg;
avg = get_sum_of_number(a);
avg /= 20;
return(avg);
}
int values::get_mean_of_number(int a[])
{
int mean;
for(i=1; i<20; i++)
{
mean += a[idx];
}
return(mean);
}
void values:: display_largest_number()
{
cout <<"The largest number is:" <<largest_number;
}
void values:: display_smallest_number()
{
cout <<"The smallest number is:" <<smallest_number;
}
void values:: display_sum_of_number()
{
cout <<"The sum of the numbers is:" <<avg;
}
void values:: display_mean_of_number()
{
cout <<"The mean of the numbers is:" <<mean;
}

Then get my main program to run it:

Code:

// ASSIGN77.CPP
// A Program to display the largest, smallest, sum and mean
#include "values.h"
#include <stdlib>
//#include "values.h"//
//#include <stdlib.h>//
void main ()
{
values arithmetic;
arithmetic.get_largest_number ();
arithmetic.get_smallest_number ();
arithmetic.get_sum_of_number ();
arithmetic.get_mean_of_number ();
arithmetic.display_largest_number ();
arithmetic.display_smallest_number ();
arithmetic.display_sum_of_number ();
arithmetic.display_mean_of_number ();
system ("pause");
}

...but it just wont run - any ideas please?

Ta

Chris