Tuesday, May 30, 2017

t6.c (done)

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

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

No comments:

Post a Comment