I typed this program
Code:
#include <stdio.h>
#define SIZE 10
int sum(int ar[], int n);
int main(void)
{
int marbles[SIZE] = {20,10,5,39,4,16,19,26,31,20};
long answer;
answer = sum(marbles, SIZE);
printf ("The total number of marbles is %ld.\n", answer);
printf ("The size of marbles is %d bytes.\n", sizeof (marbles));
return 0;
}
int sum(int ar[], int n)
{
int i;
int total = 0;
for (i = 0; i < n; i++)
total += ar[i];
printf("The size of ar is %d bytes.\n", sizeof (ar));
return total;
}
I am supose to get:
ar size of 4 bytes
total marbles of 190
marbles size of 40 bytes
what I get is:
ar size of 2 bytes
total marbles of 190
marbles size of 20 bytes
what am I doing wrong? I am really jsut trying to pass the value of an array from 1 function to the next for my assigment...