Advertisement
Guest User

-_-

a guest
Jan 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. int find_sum(int array[], int n)
  4. {
  5.     int i, sum = 0, a;
  6.     for(i = 0; i < n; i++) {
  7.         a = array[i];
  8.         sum = sum + a;
  9.     }
  10.     return sum;
  11. }
  12.  
  13.  
  14. int main()
  15. {
  16.     int array[] = {1,2,3,4,5,6,7};
  17.  
  18.     int i, count = 0;
  19.     for(auto x: array){
  20.         count++;
  21.     }
  22.     int n = count;
  23.  
  24.     int sum = find_sum(array, n);
  25.  
  26.     printf("%d\n", sum);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement