Sum of array using pointer arithmetic Read Courses Practice Improve Improve Improve Like Article Like Save Article Save Report issue Report Given an array, write a program to find the sum of array using pointers arithmetic. In this program we make use of * operator . The * (asterisk) operator denotes the value of variable. The * operator at the time of declaration denotes that this is a pointer, otherwise it denotes the value of the memory location pointed by the pointer . sum() function is used to find the sum of the array through pointers. Examples : Input : array = 2, 4, -6, 5, 8, -1Output : sum = 12 Input : array = 1, 4, -6, 8, -10, -12Output : sum = -15 CPP // CPP program to find sum of array using pointers #include <iostream> using namespace std; // Function to find the sum of the array void sum(int* array, int length) { int i, sum_of_array = 0; for (i = 0; i < length; i++) sum_of_array = sum_of_array + *(array + i); cout << "sum of array is = " << sum_of_array; } // Driver function int main() { // Array to hold the values int array[] = { 2, 4, -6, 5, 8, -1 }; sum(array, 6); return 0; } Outputsum of array is = 12 Time Complexity: O(N)Auxiliary Space: O(1) Last Updated : 21 Sep, 2022 Like Article Save Article Previous Assertions in C/C++ Next std::stod, std::stof, std::stold in C++ Share your thoughts in the comments Add Your Comment Please Login to comment...