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.
Input : array = 2, 4, -6, 5, 8, -1 Output : sum = 12 Input : array = 1, 4, -6, 8, -10, -12 Output : sum = -15
sum of array is = 12
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Double Pointer (Pointer to Pointer) in C
- Pointer to an Array | Array Pointer
- What is a Pointer to a Null pointer
- Multidimensional Pointer Arithmetic in C/C++
- Difference between pointer to an array and array of pointers
- Delete multiple occurrences of key in Linked list using double pointer
- C++ Program to count Vowels in a string using Pointer
- Trie Data Structure using smart pointer and OOP in C++
- Pointer vs Array in C
- Declare a C/C++ function returning pointer to array of integer pointers
- Difference between pointer and array in C?
- How to sum two integers without using arithmetic operators in C/C++?
- How to declare a pointer to a function?
- 'this' pointer in C++
- Type of 'this' pointer in C++
- When do we pass arguments by reference or pointer?
- How to write C functions that modify head pointer of a Linked List?
- Function Pointer in C
- Scope Resolution Operator Versus this pointer in C++?
- Opaque Pointer
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.