Question: [ 1 0 ] Textbook, Ch . 2 , Exercise 6 . C program can access an array element by dereferencing a pointer ( e

[10] Textbook, Ch.2, Exercise 6. C program can access an array element by dereferencing a pointer (e.g.,*p) or using a subscript operation [](e.g., a [5]). For example,
int arr[5]={10,20,30,40,50};
int *ptr - arr;
Both *(ptr+2) and arr [2] represent the 3rd array element, i.e.,30. Rewrite the following function, and use pointers instead of an array subscript operator.
int sum(int arr[], int n)
{
int sum =0,i;
for )=0;i
sum +=arr[i];
return sum;
{
 [10] Textbook, Ch.2, Exercise 6. C program can access an array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!