C# Program to Find the Mean of Given Numbers

This is a C# Program to find the mean of given set of numbers.

Problem Description

This C# Program Finds the Mean of given Set of Numbers.

Problem Solution

Here the sum and average of five numbers are found and displayed.

Program/Source Code

Here is source code of the C# Program to Find the Mean of given Set of Numbers. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

 * C# Program to Find the Mean of given Set of Numbers
using System;
class avg
    public static void Main()
        int n1, n2, n3, n4, n5, avg, sum;
        Console.WriteLine("Enter 5 Numbers:");
        n1 = Convert.ToInt32(Console.ReadLine());
        n2 = Convert.ToInt32(Console.ReadLine());
        n3 = Convert.ToInt32(Console.ReadLine());
        n4 = Convert.ToInt32(Console.ReadLine());
        n5 = Convert.ToInt32(Console.ReadLine());
        sum = (n1 + n2 + n3 + n4 + n5);
        avg = (sum / 5);
        Console.WriteLine("Sum :" + sum);
        Console.WriteLine("Average :" + avg);
Program Explanation

This C# program we are reading the five integer numbers using ‘n1’, ‘n2’, ‘n3’, ‘n4’, ‘n5’ variables respectively. Compute the summation of five variable values using ‘sum’ variable. Compute the division of the value of ‘sum’ variable by 5. Print the value for the sum and average of five numbers.

Runtime Test Cases
Enter 5 Numbers : 
Sum : 50
Average : 10

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

If you wish to look at all C# Programming examples, go to 1000 C# Programs.

If you find any mistake above, kindly email to [email protected]

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.