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

Program: 127

Write a function in c language that receives 5 integers and return the sum, average and standard deviation of these numbers. Call this function from main() and print the results in main().

How to return multiple values form a single function.

Output:

Enter 1st number: 2
Enter 2nd number: 3
Enter 3rd number: 5
Enter 4th number: 5
Enter 5th number: 3
The Sum: 18.000000
The Average: 3.600000
The Standard Deviation: 2.629068

Lokesh Kumar

Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.

One thought on “Q6 Write a function that receives 5 integers and return the sum, average and standard deviation of these numbers. Call this function from main() and print the results in main().

  • July 3, 2022 at 1:40 am
    Permalink

    why not to use call by refrence
    only just creating three variables in main sum,avg and stdinand remainaning variables in func variable may it reduces compilation time
    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    void func( int * ,int ,int *);
    void main()
    {
    int sum,avg,std;
    func(&sum,&avg,&std);
    printf(“sum=%d\n Average=%d\n std=%d”,);
    return 0;
    }
    void func (int *sum, int *avg, int *stdin)
    {
    int a,b,c,d,e;
    printf(“enter the numbers”);
    scanf(“%d%d%d%d%d”,&a,&b,&c,&d,&e);
    *sum=a+b+c+d+e/5;
    *avg=
    sum/5;
    stdin=sqrt((pow(a-avg),2)+(pow(b-avg),2)+(pow(c-avg),2)+(pow(d-avg),2)+(pow(e-avg),2));
    }

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.