Advertisement
Rehan_Rahman26

Function Related Problems 03

Oct 7th, 2021
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. double findAvarage(int a[], int n)
  5. {
  6.     int sum = 0;
  7.     for (int i=0; i<n; i++)
  8.     sum += a[i];
  9.  
  10.     return (double)sum/n;
  11. }
  12. int main()
  13. {
  14.     int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9,10};
  15.     int n = sizeof(arr)/sizeof(arr[0]);
  16.  
  17.     cout << findAvarage(arr, n) << endl;
  18.     return 0;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement