Mathmatical function trouble

I cant quite seem to get this totalsum function to work.
what I want it to do is if the user enters 4, it changes total to 10 (1+2+3+4=10). after trying several numbers I've determined it's adding all number except the final number (i.e user enter 4, it changes total to 6 1+2+3=6). please help me?

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
  #include <iostream>
using namespace std;

void TotalSum(int Number1, int &Total);
int OddOrEven(int N1);
void main()
{
	int Number, EvenOdd, Total=0;

	do	
	{
	cout<<"Please enter a number 1-100: ";
	cin>>Number;
		if (Number<=100)
			TotalSum(Number, Total);
		else
			break;
    EvenOdd=OddOrEven(Number);
	if (EvenOdd==1)
		cout<<"This number is even."<<endl;
	else
		cout<<"This number is odd."<<endl;
	cout<<"The total of all between 1 and "<<Number<<" are: "<<Total<<endl;
	Total=0;
	}
	while (Number<=100);
}

void TotalSum(int Number1, int &Tot)
{
	int Begin;
    for (Begin=1;Begin<Number1;Begin++)
        Tot=Tot+Begin;
}
int OddOrEven(int N1)
{
    if (N1%2==0)
        return 1;
	else
        return 2;
}
Make it:
Begin<=Number1;
... well, I feel intelligent... thank you. it works now.
Topic archived. No new replies allowed.