Advertisement
Dido09

Sum of Array - C

Mar 15th, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.  
  6. int arr[10], size, i, sum = 0;
  7.  
  8. printf("Enter array size\n");
  9. scanf("%d",&size);
  10.  
  11. printf("Enter array elements\n");
  12. for(i = 0; i < size; i++)
  13. scanf("%d",&arr[i]);
  14.  
  15. for(i = 0; i < size; i++)
  16. sum = sum + arr[i];
  17.  
  18. printf("Sum of the array = %d\n",sum);
  19.  
  20. return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement