sum+=num doesn't seem correct since that is always 10 and hence you are not actually adding the input numbers. Also, make sure you initialize sum before using it.
Here is a small sample that gets the input of 10 different numbers from the user and calculates the sum in integer and float values and dsiplay such values to the screen.
#include <iostream>
using namespace std;
int main()
{
const int num = 10;
int sum = 0;
float exact_sum = 0;
int input = 0;
cout << "Enter 10 numbers" << endl;
for (int item = 0; item < num; item++)
{
cin >> input;
sum += input;
exact_sum+=input;
}
cout << "The sum is "<< sum <<endl;
cout << "The integer average is " << sum/num << endl;
cout << "The exact average is " << exact_sum/num << endl;
return 0;
}
The output will look something like the following:
Enter 10 numbers
1
2
3
4
5
6
7
8
9
10
The sum is 55
The integer average is 5
The exact average is 5.5
Hope this helps!
Thanks,
Ayman shoukry
VC++