SHARE
TWEET

Untitled

a guest Jul 18th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int sum(int arr[], int n)
  2. {
  3.     int sum = 0; // initialize sum
  4.  
  5.     // Iterate through all elements  
  6.     // and add them to sum
  7.     for (int i = 0; i < n; i++)
  8.     sum += arr[i];
  9.  
  10.     return sum;
  11. }
  12.  
  13. int main()
  14. {
  15.  
  16.    int arr[] = {1, 3, 4, 2};
  17.     int n = sizeof(arr) / sizeof(arr[0]);
  18.     printf("Suma niza je %d", sum(arr, n));
  19.     return 0;
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top