Why it isn't working?
I am trying in this problem to calculate the summation of the most and least numbers in that array so I am comparing the values to the max and min number and putting the rest in an array and then find the summation but it ain't working so why? #include <stdio.h> #include <stdlib.h> int h[]={8,2,5,1,4}; int i,max,p,x,z,min,l,f,s,q; int k; int m[4]; int n[4]; int size=sizeof(h)/sizeof(int); void j(int h[],int size); int main() { j(h,size); printf("The min sum = %d",max); printf("The max sum = %d",f); } void j(int h[],int size){ for (i=0;i<size;i++){ for (p=i+1;p<size;p++){ if (h[i]>h[p]){ max=h[i];} } for (k=0;k<size;k++){ if(h[k]<max){ m[k]=h[k];}} z=m[0]+m[1]+m[2]+m[3]; } ///// for (s=0;s<size;s++){ for (q=i+1;q<size;q++){ if (h[s]>h[q]){ min=h[q];} for (l=0;l<size;l++){ if(h[l]>min){ n[l]=h[l]; }} f=n[0]+n[1]+n[2]+n[3]; } } }