Let us discuss SyncFusion Interview Programs with Answers here. The below program was asked for a .NET Fresher candidate in SyncFusion Interview.

SyncFusion Interview Programs:
Find the average of an array excluding highest and lowest values in the array.

SyncFusion Interview Programs with Answers

Finding the average of Array Excluding Highest, Lowest elements:

int[] arr = new int[] { 8, 8, 10,6, 8 };

if (arr.Length > 0)
{
int small = arr[0];
int large = arr[0];
for (int i = 0; i < arr.Length; i++)
{
if (large < arr[i])
{
int tmp = large;
large = arr[i];
arr[i] = large;
}
if (small > arr[i])
{
int tmp = small;
small = arr[i];
arr[i] = small;
}
}
MessageBox.Show(“smallest is ” + small.ToString());
MessageBox.Show(“largest is ” + large.ToString());
int sum= 0;
for (int i = 0; i < arr.Length;i++ )
{
if(arr[i] != small && arr[i] != large)
{
sum += arr[i];
}
}
if (sum != 0)
sum /= 3;

MessageBox.Show(” The Average of the numbers is ” + sum.ToString());

}

Please share your views also about this program.