Sum of array using pointer arithmetic Last Updated : 21 Sep, 2022 Comments Improve Suggest changes Like Article Like 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) Comment More infoAdvertise with us Next Article Sum of array using pointer arithmetic M mohitw16 Follow Improve Article Tags : Misc C Language C++ pointer cpp-pointer +1 More Practice Tags : CPPMisc Similar Reads C++ Pointer Arithmetic In C++, pointer arithmetic means performing arithmetic operations on pointers. It refers to the operations that are valid to perform on pointers. Following are the arithmetic operations valid on pointers in C++:Table of ContentIncrementing and Decrementing Pointer in C++Addition of Constant to Point 7 min read Pointer Arithmetics in C with Examples Pointer Arithmetic is the set of valid arithmetic operations that can be performed on pointers. The pointer variables store the memory address of another variable. It doesn't store any value. Hence, there are only a few operations that are allowed to perform on Pointers in C language. The C pointer 10 min read Array of Pointers in C In C, a pointer array is a homogeneous collection of indexed pointer variables that are references to a memory location. It is generally used in C Programming when we want to point at multiple memory locations of a similar data type in our C program. We can access the data by dereferencing the point 6 min read How to sum two integers without using arithmetic operators in C/C++? Given two integers a and b, how can we evaluate the sum a + b without using operators such as +, -, ++, --, ...? Method 1 (Using pointers)An interesting way would be: CPP // May not work with C++ compilers and // may produce warnings in C. // Returns sum of 'a' and 'b' int sum(int a, int b) { char * 4 min read Pointer to an Array in C++ Pointers in C++ are variables that store the address of another variable while arrays are the data structure that stores the data in contiguous memory locations. In C++, we can manipulate arrays by using pointers to them. These kinds of pointers that point to the arrays are called array pointers or 6 min read Like