Finding average of array elements - c# program, DOT NET Programming

Finding Average of Array Elements - C# Program

I need assignment help for Finding Average of Array Elements in C#. Can anybody send me there ideas?

Posted Date: 2/12/2013 1:09:55 AM | Location : United States





Hey you should implement the below code in your assignment. This is a very easy example, try it once.

Program:

using System;  

class ArrayFunction

{

  public static void Main()

 {

   long Largest;

   double Average;

   int c;

   int num;

   int[] array1;     

  Console.Write("Enter the number of Elements in an Array : ");    

  c=int.Parse(Console.ReadLine());    

  array1=new int[c];    

   for (int i=0 ; i>c ;i++)

  {

   Console.WriteLine("Enter the element " + i);

   num=int.Parse(Console.ReadLine());

   array1[i]=num;

  }  

   foreach (int i in array1)

  {

   Console.Write(" " + i);

  }  

  Console.WriteLine ();  

  Largest = Large(array1);

  Average = Avg(array1);  

  Console.WriteLine ("\n The largest element in the array is " +     Largest);

  Console.WriteLine ("The Average of elements in the array is " +    Average);

  Console.ReadLine();       

 }  

  static double Avg (params int [] arr)

 {

   double sum=0;  

   for ( int i = 0; i < arr.Length; i++)

  {

   sum = sum + arr[i];

  }

  sum = sum/arr.Length;   

   return(sum);

 }

}

Posted by Damon | Posted Date: 2/12/2013 1:11:28 AM


Related Discussions:- Finding average of array elements - c# program, Assignment Help, Ask Question on Finding average of array elements - c# program, Get Answer, Expert's Help, Finding average of array elements - c# program Discussions

Write discussion on Finding average of array elements - c# program
Your posts are moderated
Related Questions
What is difference between abstract classes and interfaces? The difference b/w abstract and interfaces are s follows:- 1.     The Abstract classes can have concrete methods

What is the use of a .disco file? A client application uses a .disco file to locate or discover the documents that have the description of a Web service. The .disco file having

Write the basic syntax of a LINQ query in Visual Basic as well as in C#. In Visual Basic, the basic syntax of a LINQ query begins with the from clause and ends with the Select

Counting Number of Words in a String - C# Program Anyone can suggest me the output of the following program. using System;   class CountWords { public static void

i want decompile ex5 files Project Description: i want decompile some ex5 files like indicators, scripts and eas i need in format mq5 can do this to me? Skills required

Windows Phone 8 camera streaming to desktop app Project Description: I require WP8 application (client) that will: 1. Automatically evaluate and connect to Windows desktop

This assignment is based on lectures, tutorials, computer labs and research work. 1. Background During the lectures and tutorials on business process modeling and business

Define Network? A network is a set of devices linked by physical media links. A network is recursively is a connection of two or more nodes by a physical link or two or more

Prepare datamodel, API and more Project Description: Dear all, we would like you to prepare database and an API which can be used in the shopping cart (checkout and delivery

What is managed code and managed data? Managed code is code that is written to target the services of the Common Language Runtime. In order to target these services, the code m