This is what I was given to start with.
int main(){
int a[5] = {0,1,2,3,4};
printf("Sum of elements of a: %d\n", calculate_sum(a,5));
return 0;
}
Here's what I've got, I don't know why it doesn't work, please help me.
#include <stdio.h>
int main()
{
int a[5] = {0,1,2,3,4};
int b;
int calculate_sum(int, int);
b = *a;
printf("Sum of elements of a: %d\n", calculate_sum(b,5));
return 0;
}
int caluculate_sum(int *a, int size)
{
int i;
int sum = 0;
for(i = 0; i < size; i = i + 1)
sum = sum + a[i];
return sum;
}