C# Program to Find the Average Values of all the Array Elements

This is a C# Program to find the average values of all the array elements.

Problem Description

This C# Program Finds the Average Values of all the Array Elements.

Problem Solution

Here the array elements are obtained from the user and the sum is first calculated. Average is then found by dividing the sum by the number of terms.

advertisement

Program/Source Code

Here is source code of the C# Program to Find the Average Values of all the Array Elements. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

In this C# program, we are reading the size of an array using ‘size’ variable. Using for loop we are entering the coefficient values of an array.

advertisement

The sumAverageElements() function is used to compute the sum of coefficient value. Find the value of ‘average’ variable by dividing the value of ‘sum’ variable by the value of ‘size’ variable. Print the average values of all the array elements.

Runtime Test Cases

Enter the Size :
5
Enter the Elements of the Array :
10
20
30
40
50
Sum of the Array is : 150
Average of the Array is : 30