num1 and num2 haven't been initialized when you make this statement.
sum = num1 + num2;
If you want the function to do the calculation, then the function can return the calculated sum to your sum variable in main.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int calculation(int number1, int number2)
{
return number1 + number2;
}
int main ()
{
int num1, num2, sum;
cout << "Enter a number: ";
cin >> num1;
cout << "Enter another number:";
cin >> num2;
sum=calculation(num1, num2);
cout << "The total is " << sum;
return 0;
}