This program will help you, try it out
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();
}
// Determining the largest array element static int Large (params int [] arr)
{
int temp=0;
for ( int i = 0; i < arr.Length; i++)
{
if (temp <= arr[i])
{
temp = arr[i];
}
}
return(temp);
}
}