#include <stdio.h>
int calculate_sum(int *ptr, int n) {
// Your logic here
int sum = 0; // intilize the sum with zero
for(int i=0;i<n;i++){ // iterate the loop n times
sum += *ptr; // add the *ptr value to sum
*ptr++; // increment the ptr
}
return sum; // return the sum value
}
int main() {
int n;
scanf("%d", &n);
int arr[100];
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
int result = calculate_sum(arr, n);
printf("%d", result);
return 0;
}
int calculate_sum(int *ptr, int n) {
// Your logic here
int sum = 0; // intilize the sum with zero
for(int i=0;i<n;i++){ // iterate the loop n times
sum += *ptr; // add the *ptr value to sum
*ptr++; // increment the ptr
}
return sum; // return the sum value
}
Input
5 1 2 3 4 5
Expected Output
15