Advertisement
18126

Day2(ex2)

Jul 7th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int sumArr(int* arr, int n) {
  6.     int sum = 0;
  7.     for(int i = 0; i < n; i++) {
  8.         sum += *(arr+i);
  9.     }
  10.     return sum;
  11. }
  12.  
  13. int main() {
  14.     int a[6] = {3, 2, 6, -1, 0, 3};
  15.     int s = sumArr(a, 6);
  16.     printf("Sum: %d", s);
  17.     return 0;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement