0

hey, i am new here but i have taken a few c++ classes.

im having trouble with a very easy program and i just cant figure out why its doing this.

ive looked around the forum already and didnt find anything helpful so i thought id ask.

```
include <iostream>
using namespace std;
int add();
int subtract();
int times();
int divide();
int main()
{
int a;
cout<<"This program is a simple calulator. Its able to + - * or /\n";
cout<<"the below table is a 'key' enter one of the numbers\n\n\n";
cout<<" 1. add\n";
cout<<" 2. subtract\n";
cout<<" 3. times\n";
cout<<" 4. divide\n\n";
cout<<" ";
cin>>a;
cout<<"\n\n";
if (a==1)
add();
else if (a==2)
subtract();
else if (a==3)
times();
else if (a==4)
divide();
else
cout<<"you didnt enter a valid number.\n\n";
system("PAUSE");
return 0;
}
int add()
{
int num, sum=1;
cout<<"how many numbers would you like to add?\n";
cin>>num;
for (int i=1;i<num;i++)
{
int array[i];
sum+=array[i];
}
cout<<"Your new number is "<<sum<<"\n\n\n";
}
```

its able to run, but when i enter any number for the amount of numbers to add, it prints out some long number like 257487465896546549876546

my question is why is it giving me that long number and how can i fix it?