Program crashing upon variable input

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.

Here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  #include <iostream>
#include <iomanip>
using namespace 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)
{
	static int 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
Last edited on
A couple of obvious problems:
Line 20,33: You're using the assignment operator (=), not the equality operator (==).

Line 30: You initialize count to zero.
Line 34: The first time you call sumNumbers, you attempt to divide by zero.


After fixing my very foolish grammar errors, it works! Thanks so much!
Topic archived. No new replies allowed.