-
1 Attachment(s)
Slope Intercept Form
I have attached the original problems and below is what I have started. It compiles with this warning "geometry.c:9: warning: built-in function 'y1' declared as non-function" help please. . Thanks!
Code:
#include <stdio.h>
/* Function Prototypes */
int a;
double m, x1, x2, y1, y2;
int get_problem (int a);
double get2_pt (double x1, double x2, double y1, double y2);
double get_pt_slope (double m, double x1 , double y1);
/*double slope_intcpt_from2_pt
double intcpt_from_pt_slope
double display2_pt
double display_pt_slope
double display_slope_intcpt*/
int main (void)
{
get_problem (a);
return (0);
}
int get_problem (int a)
{
printf("Select the form that you would like to convert to slope-\n");
printf("intercept form:\n");
printf("1) Two-point form (you know two points on the line)\n");
printf("2) Point-slope form (you know the line's slope and one point)\n");
printf("=>");
scanf("%d", &a);
if (a==1) {
get2_pt (x1, x2, y1, y2);
}
else if (a==2) {
get_pt_slope (m, x1, y1);
}
}
double get2_pt (double x1, double x2, double y1, double y2)
{
printf("Enter the x-y coordinates of the first point separated by a");
printf("space=> ");
scanf("%lf %lf", &x1, &y1);
printf("Enter the x-y coordinates of the second point separated by a");
printf("space=> ");
scanf("%lf %lf", &x2, &y2);
}
double get_pt_slope (double m, double x1, double y1)
{
printf("Enter the slope=> ");
scanf("%lf", &m);
printf("Enter the x-y coordinates of the point separated by a space=> ");
scanf("%lf %lf", &x1, &y1);
}
-
Remove all your global variables, especially the one called y1, and use local variables in the appropriate scope.
Because you've named all your formal parameters the same, only your 'a' variable has any purpose at all.
And since they're all passed by value, where you actually read the values in has no effect on the caller.