arithmetic average return calculator code example
Example: average calculator
1. make an array nums[number of neumbers you will calculate the average of]
wich will store the numbers and a variable sum=0 (make it double)
2. input that array with a loop
3. in the loop, after you have entered nums[i] add it to sum
4. after loop output sum divided by the number of numbers
code in c++:
using namespace std;
int main()
{
long long nums[ 5 ];
double sum = 0;
for( long long i = 1 ; i <= 5 ; i++ )
{
cin >> nums[ i ];
sum += nums[ i ];
}
cout << sum / 5 << endl ;
return 0;
}