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!
download android app

Popular C Examples









codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube