#include "stdio.h" float slope(float rise, float run) { /*declaring variables*/ int x1; int y1; int x2; int y2; /*equation to find slope of line, where m=slope*/ rise=y2-y1; run=x2-x1; return rise/run; } float intercept(float y1, float slope, float x1) { /*equation of the line*/ return y1-(slope*x1); } int y_coordinate(float slope, float x, float intercept) { /*equation to find the y coordinate*/ return slope*x+intercept; } int x_coordinate(float y, float intercept, float slope) { /*equation to find the x coordinate*/ return (y-intercept)/slope; } int main() { /*declaring variables*/ int x1; int y1; int x2; int y2; float x; float y; float intercept; float slope; float rise; float run; int a = 1; while (a != 0) { /*user input*/ printf("x1: "); scanf("%d", &x1); printf("y1: "); scanf("%d", &y1); printf("x2: "); scanf("%d", &x2); printf("y2: "); scanf("%d", &y2); /*using previous functions to calculate the equation of the line*/ y = slope(rise, run)*x + intercept(y1, slope, x1); /*print equation of the line*/ printf("y = %fx + %f\n", slope, intercept); /*user input for x value*/ printf("Enter a value for x: "); scanf("%f", &x); /*using previous function to find y-intercept*/ y= y_coordinate(slope, x, intercept); /*print y coordinate*/ printf("y = %f\n", y); /*user input for y value*/ printf("Enter a value for y: "); scanf("%f", &y); /*using previous function to find x-intercept*/ x= x_coordinate(y, intercept, slope); /*print x cooridinate*/ printf("x = %f\n", x); /*user input to decide whether or not to continue*/ printf("Enter 0 to quit, 1 to continue: "); scanf("%d", &a); } return 0; }