Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Ask for expert help: ask for C language code: given a plastic array of 10 elements, find the sum of all the element values with odd subscripts. thank you
Ask for expert help: ask for C language code: given a plastic array of 10 elements, find the sum of all the element values with odd subscripts. thank you
# include & ltstdio.h & gt

Int sum _ idx _ Ji Shu (int *arr, unsigned I)

{

int sum = 0;

If (! arr)

return- 1;

for(; I>0; I-)

{

If (0! = (i - 1)%2)

sum+= arr[I- 1];

}

Returns the sum;

}

int main()

{

int arr[ 10]= { 0 }; /* The value of a specific array can be changed at will */

Int result;

Result = sum(arr,10);

Printf ("Result: %d\n", result);

}