OK, you seem to be on a hunt for questions.... here's one for you.
Here's some code that works.... or does it?!
Code:
/*
* sample1.c
* This program adds up the values in the array,
* and prints the results to the screen
*/
#include <stdio.h>
int Adder(int a[])
{
int i;
int myTotal;
for (i = 0; i < sizeof(a); i++)
myTotal += a[i];
return myTotal;
}
int main(void)
{
int myarray[6] = {5, 1, 3, 2, 4};
int Total;
Total = Adder(myarray);
printf ("The total of the %d elements is %d\n", sizeof(myarray), Total);
return(0);
}
As you've guessed/worked out, it doesn't do what it's supposed to. Explain the problems and suggest some corrections.