Answer:
C# codee
using System;
class IntegerFacts
{
static void Main()
{
int[] x = new int[10];
int sum = 0;
int siz = 0, high = 0, low = 0, avg = 0;
siz = FillArray(x);
Statistics(x, ref high, ref low, ref sum, ref avg, siz);
Console.Write("The highest value is " + high);
Console.Write("\nThe lowest value is " + low);
Console.Write("\nThe sum of the values is " + sum);
Console.Write("\nThe average is " + avg);
}
static void Statistics (int [] b, ref int h, ref int l, ref int s, ref int a, int size)
{
if (size == 0)
h = l = s = a = 0;
else
{
int i =0;
l = 999;
h = 0;
s = 0;
for (; i < size;++i)
{
if(b[i] > h)
h = b[i];
if(b[i] < l)
l = b[i];
s += b[i];
}
a = s / size;
}
}
static int FillArray (int[] a)
{
int i = 0, count = 0;
int intTemp =0 ;
string temp;
for(i = 0 ; i < 10 ; i++)
{
Console.Write("Enter element number"+(i+1) +" : ");
temp = Console.ReadLine();
if (int.TryParse(temp, out intTemp)) {
if (intTemp != 999)
{
a[i] = intTemp;
count++;
}
else
break;
}
else
{
Console.Write("\n\nOops.. You entered a wrong number. Try again \n\n");
i--;
}
}
return count;
}
}
Explanation:
The output of the above program is given in the attached file.