

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Program to find the average of a sequence of numeric values
Use the Linq Average() method to find the average of a sequence of numeric values.
Firstly, set a sequence.
List<int> list = new List<int> { 5, 8, 13, 35, 67 };
Now, use the Queryable Average() method to get the average.
Queryable.Average(list.AsQueryable());
Example
using System; using System.Linq; using System.Collections.Generic; class Demo { static void Main() { List<int> list = new List<int> { 5, 8, 13, 35, 67 }; double avg = Queryable.Average(list.AsQueryable()); Console.WriteLine("Average = "+avg); } }
Output
Average = 25.6
- Related Questions & Answers
- C# Program to find the sum of a sequence
- C++ program to find sequence of indices of the team members
- How to find the Average Values of all the Array Elements in C#?
- C++ Program to Find the Longest Increasing Subsequence of a Given Sequence
- C++ Program to Find the Longest Prefix Matching of a Given Sequence
- Program to find sum of given sequence in C++
- C program to calculate range of values and an average cost of a personal system.
- How to find the average of non-zero values in a Python dictionary?
- Create a MySQL function and find the average of values in a column
- 8086 program to find average of n numbers
- How to compute Average for the Set of Values using C#?
- Find the average of column values in MySQL using aggregate function
- MySQL query to find the average of only first three values from a column with five values
- C# Program to invert the order of elements in a sequence
- Java program to find the average of given numbers using arrays
Advertisements