SyncFusion Interview Programs with Answers
This blog explains about SyncFusion Interview Programs with Answers and is explained below :
______________________________________________________________________________
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 with Answers
Finding the average of Array Excluding Highest, Lowest elements in the array :
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());
}
Java Code:
Original Array: [5, 7, 2, 4, 9]
Compute the average value of an array of integers except the largest an
d smallest values: 5.33
Please share your views also about this program.
_______________________________________________________________________________________