Computer Science, asked by piyush365, 1 year ago

Write an interactive C program to calculate the sum of array elements using

pointer.

Answers

Answered by bellarina
0
an interactive C program to calculate the sum of Array elements using pointer ,
Answered by Prathamesh1810
0
⏬ Hello Friend Here Is Your Answer ⏬

/*

  * C program to read N integers and store them in an array A. 

* Find the sum of all these elements using pointer. 

*/ #include <stdio.h>#include <malloc.h> void main()

{

int i, n, sum = 0; int *a; 

printf("Enter the size of array A \n");

scanf("%d", &n); 

a = (int *) malloc(n * sizeof(int)); 

printf("Enter Elements of First List \n");

for (i = 0; i < n; i++) { scanf("%d", a + i);



</* Compute the sum of all elements in the given array

*/  for (i = 0; i < n; i++)
{

sum = sum + *(a + i);


printf("Sum of all elements in array = %d\n", sum); 

}

}

*hope it helped you*

Prathamesh1810: mark me as brainliest
Prathamesh1810: thanks
Similar questions