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
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));
}