1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <stdio.h>
int sum_negative_elements( int a[], int length )
{
/* put your code here. Remember, the length of the
array is 'length', not '10'. */
}
int main()
{
/* here I have an array that is in the program. you might want to
make the array and then get the user to enter as many elements
(for n <= LEN) as he wants... */
static int LEN = 11;
int values[ LEN ] = { 1, 43, -19, 27, 512, -7, -3, 32, 112, -20000, 8 };
/* you might want to do something like print the array here? */
/* (but you don't have to) */
int sum = sum_negative_elements( values, LEN );
/* print the result */
printf( "The negative elements sum to %d\n", sum );
return 0;
}
|