C Programming
- Print integer
- Add & subtract
- Odd & even
- Multiply & divide
- Check vowels
- Letter grade program
- Leap year program
- Sum of digits
- Prime numbers
- Sum of numbers
- Find factorial
- Fibonacci series
- Fibonacci triangle
- Number triangle
- Alphabet triangle
- Armstrong numbers
- Palindrome numbers
- Swap number
- Reverse number
- Decimal to binary
- Assembly code in C
- Matrix multiplication
- HCF & LCM
- nCr & nPr
- Print pattern
- Floyd’s triangle
- Pascal triangle
- Count digits
- Strong numbers
- Perfect numbers
- Sum of natural number
- Binary to decimal
- Decimal to octal
- Octal to decimal
- Binary to octal
- Octal to binary
- Add using pointer
- Bubble sort
- Insertion sort
- Selection sort
- Quick sort
- Binary search
- Linear search
- Largest element of array
- Smallest element of array
- Reverse Array
- Variable size & limit
- ASCII value of character
- Sum of array elements
- Number of element in array
- Merge two array
- Insert element in array
- Delete element from array
- Add two matrix
- Transpose matrix
- Print string
- Reverse string
- Delete vowels
- Sort string
- Remove spaces
- Swap string
- Random numbers
- Print date & time
- Print IP address
- Shut down computer
Determining sum of array elements
Sum of array element is the result of addition of all the element of an array. We can do it using different logic. We will see some most relevant way to determine the sum of array element using C programming.
Sum using function or recursion, pointers as well as loop. Let’s see some C program bellow;
C program to find sum of array elements
// determine sum of array element
#include <stdio.h>
int main(){
int Num, k, result = 0;
printf("Enter how many integers of the array : ");
scanf("%d", &Num);
int my_array[Num];
printf("Enter all integers of array : \n");
for(k = 0; k < Num; k++){
scanf("%d", &my_array[k]);
}
for(k = 0; k < Num; k++){
result += my_array[k];
}
printf("\nSum is = %d\n", result);
return 0;
}
Output of the sum of array program :

Sum of array element using pointer in C
// sum of array element using pointer in c
#include<stdio.h>
int main(){
int sum_array[30], result = 0, j, Num, *ptr;
printf("Enter how many element in array : ");
scanf("%d", &Num);
printf("Enter all element of array : \n");
for(j = 0; j < Num; j++){
scanf("%d", &sum_array[j]);
}
ptr = &sum_array;
for(j = 0; j < Num; j++){
result = result + *ptr;
ptr++;
}
printf("\nSum of all array element is = %d\n", result);
return 0;
}
Output of program
Enter how many element in array : 7
Enter all element of array :
10 20 30 40 50 60 70
Sum of all array element is = 280
You can write the same logic using function to calculate the sum of array elements. You should do this in your own. However, the logic will be same for other type of data like float, double etc.
Previous page:Â ASCII value of character
Next page:Â Number of element in array