The average is the outcome from the sum of the numbers divided by the count of the numbers being averaged.
For example: 1,2,3,4,5
Number of all elements = 5
Sum of all elements = 1+2+3+4+5 =15
Average = Sum of all elements / number of all elements = 15/5 =3
Average =3
Algorithm
- STEP 1: START
- STEP 2: DEFINE n.
- STEP 3: SET count = 1
- STEP 4: DEFINE xF, averageF
- STEP 5: SET sumF = 0
- STEP 6: ENTER n
- STEP 7: REPEAT STEP 8 to 10 UNTIL count<=n
- STEP 8: Enter xF
- STEP 9: sumF += xF
- SETP 10: count = count + 1
- SETP 11: SET averageF = sumF/(n-1)
- STEP 12: PRINT averageF
- STEP 13: END
Java Program
Output:
C program
Output:
Python program
Output:
Php program
Output:
C# program
Output: