Hey everyone,
I'm new to this site, but wish I could have found it sooner! I'm taking an online programming course and therefore have limited availability in contacting my instructor for questions about the assignments/text... and this assignment in particular is stumping me even after going through a few old tutorials.
I have the code somewhat close to what it needs to be... I hope! But I can't remember, or maybe I never actually knew, how to let a user assign a value to the array and then enter their own array numbers.
Also, I think I'm having a compatability problem with my compiler again with the #define line.....
Suggestions/Help? Please :)
I have a feeling some of this may be extranneous coding, but its the user definition that seems to be giving me trouble.Code:/* SUMARRAY Marco use */
#include <stdio.h>
#include <stdlib.h>
#define SUMARRAY(a, num_elements) for (i=0; i < num_elements; i++) sum = sum + a[i]; sum;
int main( void )
{
int x;
int l;
int d;
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<x; l++){
printf("Enter number you wish to sum, then press ENTER: \n");
scanf("%d", &d);
}
sum = SUMARRAY(a[i], x);
printf("The sum is %d\n", sum);
system ("PAUSE");
return 0;
}

