C++ program to find average of 10 numbers

Write a C++ program to find the average of 5 numbers.
#include<iostream>
using namespace std;
// main function
int main()
{
  // variables to store input values
  double Numb1, Numb2, Numb3, Numb4, Numb5 , Numb6 ,Numb7 ,Numb8 ,Numb9 ,Numb10;
  double Average; // to store result

  //  input values by the user
  cout << "Enter ten
   Numbs: ";
  cin >> Numb1 >> Numb2 >> Numb3 >> Numb4 >> Numb5, Numb6 ,Numb7 ,Numb8 ,Numb9 ,Numb10;
  
  // calculating the average value
  Average = (Numb1 + Numb2 + Numb3 + Numb4 + Numb5, Numb6 ,Numb7 ,Numb8 ,Numb9 ,Numb10)/10;
  
  // show result
  cout << "Average = " << Average << endl;

  return 0;
}

Output

Enter five numbers: 44
33
2
34
55
8
6
4
5
6
Sum = 197
Average = 19.7

Write a C++ code to find the average of 5 numbers using for loop and array.

#include<iostream>
using namespace std;
// main function
int main()
{
  // Array  to store 10 numbers
  double T4Tutorials[10]; 
  double sum; // to store sum 
  double avg; // to store result

  // take input values
  cout << "Enter five numbers: ";
  for (int loop = 0; loop  < 10; ++loop )
  {
    cin >> T4Tutorials[loop ];
  }
  
  // calculate sum value
  sum = 0;
  for (int loop  = 0; loop  < 10; ++loop )
  {
    sum += T4Tutorials[loop ];
  }

  // calculate average value
  avg = sum/10;
  
  // display result
  cout << "Sum = " << sum << endl;
  cout << "Average = " << avg << endl;

  return 0;
}

Output

Enter five numbers: 44
33
2
34
55
8
6
4
5
6
Sum = 197
Average = 19.7

C++ program to find the average of 5 numbers

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.