Thread: Slope Intercept Form

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    4

    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("&#37;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);
    
    
    }
    Attached Images Attached Images
    Last edited by Salem; 11-04-2007 at 01:27 AM. Reason: Snip IM/email addresses

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reopening a form ?
    By Aga^^ in forum C# Programming
    Replies: 1
    Last Post: 02-11-2009, 09:28 AM
  2. Calling datas from another form?
    By Aga^^ in forum C# Programming
    Replies: 2
    Last Post: 02-06-2009, 02:17 AM
  3. Accessing main form from functions in other classes
    By pj_martins in forum C++ Programming
    Replies: 1
    Last Post: 11-05-2004, 09:27 AM
  4. My UserControls dissapear off my form
    By zMan in forum C# Programming
    Replies: 2
    Last Post: 09-15-2004, 08:55 AM
  5. Making an MFC form to suit
    By TJJ in forum Windows Programming
    Replies: 1
    Last Post: 04-17-2004, 11:20 AM