Wednesday, May 31, 2017

t6.c (done)

#include<stdio.h>
#include <math.h>

int main (void)
{
    int result = 0;
    float i;
    float smallest =0, largest=0, total=0;
    int eachNewline = 0;
    while (result != EOF)
    {
        result = scanf ("%f",&i);
        if(smallest ==0 && largest == 0 && total == 0){
                smallest = i;
                largest = i;
        }
        if (result == EOF){ break;}
        if (i<smallest){
            smallest = i;
        } else if (i>largest){
            largest = i;
        }
        total = i + total;
        eachNewline++;
    }
    printf("%.2f %.2f %.2f\n", smallest, largest, (total/eachNewline));
    return 0;
}





No comments:

Post a Comment