All pastes #100742 Raw Edit

kalipay fow

public text v1 · immutable
#100742 ·published 2006-07-26 12:02 UTC
rendered paste body
#include<stdio.h>
#include<conio.h>
#define max 7

void input(float scores[], int size);
float largest(float scores[], int size);
float smallest(float scores[], int size);
float average(float scores[], int size, float *largest, float *smallest);

void main(void){

float scores[max];
float L, S, A;
clrscr();

input(scores, max);
L=largest(scores, max);
S=smallest(scores, max);
A=average(scores, max, &largest, &smallest);
printf("average is: %f", A);
getch();
}

void input(float scores[], int size){
int i;

   for(i=0; i<size; i++){
      printf("Enter a float value: ");
      scanf("%f", &scores[i]);
   }
}

float largest(float scores[], int size){
int i, temp, *largest;

   temp=scores[0];
   for(i=0; i<size; i++){
      if(scores[i]>temp)
	 temp=scores[i];
   }
   *largest=temp;
   return *largest;
}

float smallest(float scores[], int size){
int i, temp, *smallest;

   temp=scores[0];
   for(i=0; i<size; i++){
      if(scores[i]<temp)
	 temp=scores[i];
   }
   *smallest=temp;
   return *smallest;
}

float average(float scores[], int size, float *largest, float *smallest){
int i;
float sum=0, ave;

   for(i=0; i<size; i++){
      if(scores[i]!=*largest && scores[i]!=*smallest)
	 sum=sum+scores[i];
   }
   ave=sum/(size-2);
   return ave;
}