Think about where you want the user's typed number to go. Hint: The answer "a" you have in your code is not specific enough.
Although this was a open ended hint, it was perfect! Thanks for pointing me in the right direction without doing it for me.
I managed to fix the program by rewriting that line as
Code:
for (l=0; l<num_elements; l++){
printf("Enter number you wish to sum, then press ENTER: \n");
scanf("%d", &a[l]);
}
and the program now reads:
Code:
/* SUMARRAY Marco use */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SUMARRAY(a, num_elements) for (i=0; i < num_elements; i++) sum = sum + a[i]; sum;
int main( void )
{
int l;
int i;
int sum = 0;
int num_elements;
printf("Enter the number of numbers to be summed up to 20: \n");
scanf("%d", &num_elements);
int a[20] = {};
for (l=0; l<num_elements; l++){
printf("Enter number you wish to sum, then press ENTER: \n");
scanf("%d", &a[l]);
}
SUMARRAY(a, num_elements);
printf("The sum is %d\n", sum);
system ("PAUSE");
return 0;
}
Thanks again, everyone