I am having trouble compiling this program. If somebody could take a look and see if my code is sound or not i would much appreciate it. I am worried that my logic and commands might be flawed, if someone could help me out I would much appreciate it.
I attached the output I am supposed to be getting...
#include <stdio.h>
int
main()
{
int num,
x1,
y1,
x2,
y2,
float y_int,
m,
x_int; // basic floating point variables. m is slope etc.
char quit; // takes a single letter if you don't want to quit, explained later.
printf ("Select the form that you would like to convert to slope-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=>");
scanf("%d",&num);
switch(num)
{
case 1:
do {
printf("Enter the x-y coordinates of the first point separated by a space=> ");
scanf("%d", &x1);
scanf("%d", &y1);
printf("Enter the x-y coordinates of the second point separated by a space=> ");
scanf("%d", &x2);
scanf("%d", &y2);
printf("\n");
printf("Two-point form");
printf(" (%d - %d)\n m = -------------\n (%d -%d)\n",y2,y1,x2,x1);
/*CALCULATIONS*/
m = ( y2 - y1 ) / ( x2 - x1 ); /*SLOPE*/
y_int = y1 - (m * x1); /*Y_INTERCEPT*/
x_int = -y_int / m; /*X_INTERCEPT*/
if (y_int > 0) printf("\nSlope-intercept form\n Y = %.2fx + %.1f\n", m, y_int);
else printf("\nYour slope-intercept equation is: Y = %.2fx + %.1f\n", m, y_int);
printf("Do another conversion (Y or N)=> ");
scanf("%s", &quit);
}
while (quit == 'N' || quit =='n');
case 2:
do {
printf("Enter the slope=> ");
scanf("%f", &m);
printf("Enter the x-y coordinates of the second point separated by a space=> ");
scanf("%d", &x1);
scanf("%d", &y1);
printf("\n");
printf("Point-slope form");
printf(" y - %d = %f(x - %d)\n",y1,m,x1);
/*CALCULATIONS*/
y_int = y1 - (m * x1);
if (y_int > 0) printf("\nSlope-intercept form\n Y = %.2fx + %.1f\n", m, y_int);
else printf("\nYour slope-intercept equation is: Y = %.2fx + %.1f\n", m, y_int);
printf("Do another conversion (Y or N)=> ");
scanf("%s", &quit); }
return(0);