-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArray_total_sum.c
More file actions
41 lines (34 loc) · 768 Bytes
/
Array_total_sum.c
File metadata and controls
41 lines (34 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// find average weight of number of arr
// author: jaydattpatel
#include<stdio.h>
float average_fun(float x[],int size)
{
float sum,avg;
for(int i=0;i<size;i++)
{
sum = x[i] + sum;
}
avg = sum/size;
return(avg);
};
void display(float x[],int size)
{
for(int i=0;i<size;i++)
printf("%d.%f\n",i,x[i]);
};
int main()
{
int size;
float average;
printf("Enter array size: ");
scanf("%d",&size);
float arr[size];
for(int i=0;i<size;i++)
{
printf("%d Enter : ",i+1);
scanf("%f",&arr[i]);
}
average = average_fun(arr,size);
printf("Average = %f",average);
return 0;
}