Advertisement
Zeshin

Day2task2

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