# Thread: NEED HELP! I'm stuck.

1. ## NEED HELP! I'm stuck.

I'm trying to solve this question but I'm stuck.

Q) Write a function, getData(arrX[], arrY[], numValues), that accepts two arrays and an integer value. The function will read from user a set of data points (x and y) and populate the two arrays accordingly - arrX stores x coordinates, arrY stores y coordinates. The function will repeatedly read x and y until user enters -999 for x value and the function returns the number of data points read and update the numValues with the number of x,y points read from the file. The function does not return any value.

My solution:

Code:
```#include <stdio.h>
void getData(double arrX[], double arrY[], int numValues);
int main(void)
{
double x, y;
int numValues;

printf("Enter x, y: ");
scanf("%lf %lf", &x, &y);
getData(&x, &y, numValues);
return 0;
}

void getData(double arrX[], double arrY[], int numValues)
{
while (1) {
double x, y;
printf("Enter x, y: ");
if (x == -999) {
break;
} else {
arrX[numValues] = x;
arrY[numValues] = y;
numValues += 1;
}
}
}``` 2. Do you realize that in main() x and y are single doubles, not two arrays of double as your function expects? 3. Hi, I just started my c programming so I'm really bad at it. 4. So how does "I'm really bad at it" relate to the problem at hand?

What exactly don't you understand? 5. Popular pages Recent additions double, function, int, numvalues, read 