clinically-proven

qq

Feb 5th, 2021
1,906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. float calculateSum(float age[]);
  3.  
  4. int main() {
  5.     float result, age[] = {23.4, 55, 22.6, 3, 40.5, 18};
  6.  
  7.     // age array is passed to calculateSum()
  8.     result = calculateSum(age);
  9.     printf("Result = %.2f", result);
  10.     return 0;
  11. }
  12.  
  13. float calculateSum(float age[]) {
  14.  
  15.   float sum = 0.0;
  16.  
  17.   for (int i = 0; i < 6; ++i) {
  18.         sum += age[i];
  19.   }
  20.  
  21.   return sum;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment