I have a function that prints out 11 points of a quadratic function ax^2 + bx + c with a, b, c as input. The function works fine except I need to use structures, not just variables x and y. How can I get my function to return a structure value and store it in a structure array then print out the structure array?
struct point {
int x;
int y;
};
struct point *findpoint(int a, int b, int c){
int i, x, y;
x = -5;
for (i = 0; i < 11; i++)
{
y = (a * (x * x)+ (b * x) + c);
printf("The points are {%d, %d}\n", x, y);
x++;
}
}
struct point arr_point[11];
int main(int argc, char *argv[]){
struct point *ptr;
printf("Enter coefficients a, b, c:");
int a, b, c;
int i;
for (i = 0; i < argc; i++){
scanf("%d %d %d", &a, &b, &c);
}
printf("%d %d %d\n", a, b, c);
findpoint(a, b, c);
return 0;
}
mainroutine to create an array of structures, thefindpointroutine to return one structure per call, and themainroutine to store that structure in its array, (b) themainroutine to create an array of structures and thefindpointroutine to directly store values in one element of that structure per call, (c) themainroutine to create an array of structures and thefindpointroutine to store values in all of those structures in one call, (d) thefindpointroutine to create an array of structures and return it, filled in, or (e) something else?