Calculate Sum of Array Elements in C

Google Advertisements

Prev Tutorial Next Tutorial

Find Sum of Array Elements Program in C

Sum of all Array elements means add all array Elements. Suppose we have 4 Elements in array and we want to find there sum.
arr[0]=4
arr[1]=2
arr[2]=1
arr[3]=6
Sum off all above elements are
arr[0]+arr[1]+arr[2]+arr[3]=4+2+1+6=13

Find Sum of Array Elements Program in C

#include<stdio.h>
#include<conio.h>

 void main()
  {
   int arr[20],i,n,sum=0;
   clrscr();
   printf("How many elements you want to enter: ");
   scanf("%d",&n);
   printf("Enter any %d elements in Array: ",n);
   for(i=0;i<n;i++)
   {
   scanf("%d",&arr[i]);
   }
   printf("Sum of Array Elements: ");

   for(i=0;i<n;i++)
   {
    sum=sum+arr[i];
   }
   for(i=0;i<n;i++)
   {
   }
  printf("%d ",sum);
  getch();
  }

Output

How many elements you want to enter : 5
Enter any 5 elements in Array: 
1 4 2 7 5
Sum of Array Elements: 19 

Prev Tutorial Next Tutorial

Google Advertisements

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs