C Program to Calculate Sum of Array Elements(Integer)



In this program we will take an array of integer element as an input from user and calculate the sum of elements.



  1. //C program to find sum of array elements
  2. #include<stdio.h>
  3. #include <conio.h>
  4. int main()
  5. {
  6. int c[100],i,n,sum=0;
  7. printf("Enter size of the array : ");
  8. scanf("%d",&n);
  9. printf("Enter elements in array : ");
  10. for(i=0; i<n; i++)
  11. {
  12. scanf("%d",&c[i]);
  13. }
  14. for(i=0; i<n; i++)
  15. {
  16. sum+=c[i];
  17. }
  18. printf("sum of array is : %d",sum);
  19. return 0;
  20. }

Output


Output!