HElp with functions
I need help with the very last function at the bottom called COMPARE...it has really been getting on my nerves because it is saying i have not initialized one of my variables...
The program is designed to prompt the user to enter positive numbers
//less than a thousand and continue until the user enters 0.
//Then it determines the 2 biggest and the 2 smallest of the input numbers.
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
void bigs (int,int&,int&);
void smalls (int,int&,int&);
void compare (int&,int&,int&,int&,int&);
int main ()
{
int number ;
int counter;
int a = 1001;
int b = 1001;
int x = 0;
int y = 0;
cout << "Enter a number:";
cin >> number;
while (number>=1 && number<=1000)
{
counter++;
bigs(number,a,b);
smalls(number,x,y);
if (counter>=3)
compare(number,a,b,x,y);
cout << "Enter a number:" << endl;
cin >> number;
}
return 0;
}
void bigs(int number, int& a, int& b)
{
if(a<number)
a=number;
}
void smalls(int number, int& x, int& y)
{
if(x<number)
x=number;
}
void compare(int& number, int& a, int& b, int& x, int& y)
{
cout<<a-number<<endl;
cout<<b-number<<endl;
cout<<number-x<<endl;
cout<<number-y<<endl;
}

