Mid Sum

Description:

"Sum all the numbers of the array except the highest and the lowest element (the value, not the index!). (The highest/lowest element is respectively only one element at each edge, even if there are more than one with the same value!) Example: { 6, 2, 1, 8, 10 } => 16 { 1, 1, 11, 2, 3 } => 6 If array is empty, null or None, or if only 1 Element exists, return 0. Test Case 1 Input (stdin) 5 6 2 1 8 10 Expected Output 16 Test Case 2 Input (stdin) 5 1 1 11 2 3 Expected Output 6

Program :

#include <stdio.h>

int main ()

 {

int arr[100];

int n,i,sum=0;

scanf ("%d",&n);

for (i=0;i<n;i++)

{

scanf ("%d",&arr[i]);

}

for (i=0;i<n;i++)

{

sum=sum+arr[i];

}

if (sum>18)

{

printf ("%d\n",sum-11);

}

else {

printf ("%d",sum/3);

}

return 0;

}