Function that receives 5 integers and returns the sum, average and standard deviation of these numbers. Call this function from main( ) and print the results in main( ).

#include <stdio.h>


float convert(int a, int b, int c, int d, int e, float *sum, float *avg, float *sd)

{

    *sum=a+b+c+d+e;

    *avg=*sum/5;

    *sd=((a-*avg)*(a-*avg)+(b-*avg)*(b-*avg)+(c-*avg)*(c-*avg)+(d-*avg)*(d-*avg)+(e-*avg)*(e-*avg))/5;

}


int main()

{

    int a, b, c, d, e;

    float sum, avg, sd;

    

    printf("Enter the numbers\n");

    scanf("%d%d%d%d%d", &a,&b,&c,&d,&e);

    

    convert(a, b, c, d, e, &sum, &avg, &sd);

    

    printf("The sum is \n %f", sum);

    printf("\naverage is \n %f", avg);

    printf("\nstandard deviation is \n %f", sd);


    return 0;

}


Comments