Click here to Skip to main content
15,887,322 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to calculate the average of 25 values out of 10..plz help me..
Posted
Comments
[no name] 16-Oct-12 3:24am    
Please explain it more efficiently.

You can use simple calculation logic for that.
Thanks
Sushil Mate 16-Oct-12 3:25am    
omg.. what you want to do here? since when you started programming??
Zoltán Zörgő 16-Oct-12 3:30am    
"average of 25 values out of 10" - how that?! How can you calculate average from more values than you have?
Member 9492907 22-Oct-12 8:15am    
sorryyyyy...i had solved it..

1 solution

C#
using System;
using System.Linq;

class Program
{
    static void Main()
    {
    //
    // Use Average to compute average value.
    //
    double[] array1 = { 1, 2, 3, 5, 0 };
    double average1 = array1.Average();
    Console.WriteLine(average1);
    //
    // Use Average to compute average string length.
    //
    string[] array2 = { "dog", "cat", "perls" };
    double average2 = array2.Average(x => x.Length);
    Console.WriteLine(average2);
    }
}
 
Share this answer
 
Comments
SoMad 8-Mar-13 3:21am    
Answer ripped off from http://www.dotnetperls.com/average[^]

Soren Madsen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900