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);
char    quit;
scanf("%s", &quit);

Take a look at that format specifier and find out why is wrong.

while (quit == 'N' || quit =='n');

That translates into English to something like this:
Loop for as long as quit is equals to a N or n
Why would that be wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.