Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #define pi acos(-1)
- double avg(int arr[],int size)
- {
- int sum=0;
- for(int i=0;i<size;i++)
- sum+=arr[i];
- double average = (sum*1.0)/(size*1.0);
- return average;
- }
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int n;
- cin >> n;
- int arr[n];
- for(int i=0;i<n;i++)
- cin >> arr[i];
- printf("Average value = %.2lf\n",avg(arr,n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement