I'm trying to make a program that enables you to input an indeterminate amount of numbers, then, when you hit 0, it displays the amount of numbers you've entered, the sum, and the average. However, every time I try to run the program, after I enter the first number, whether it is 0 or anything else, the program instantly crashes.
#include <iostream>
#include <iomanip>
usingnamespace std;
int sumNumbers(int num, int &sum, bool send);
int main()
{
int total;
bool send;
total = 0;
while (!cin.eof()){
int Number;
cout << "Please input a number to be summed, input 0 for count, sum, and average: ";
cin >> Number;
cout << endl;
if(Number = 0) sumNumbers(Number,total,true);
else sumNumbers(Number,total,false);
}
system("pause");
return 0;
}
int sumNumbers(int num, int &sum, bool send)
{
staticint count = 0;
cout << fixed << showpoint << setprecision(1);
if (send = 1) {
cout << "/n" << count << " numbers with a sum of " << sum << " and an average of " << (sum/count);
cout << endl;
}
else {
sum = sum + num;
count++;
}
return 0;
}
Thanks in advance for taking a look and aiding me in my issue.
--Zephyre