what am i doing wrong here. it compiles and works but after you enter in
the first value it just stops. 
/* 
        AUTHOR:            Christopher A. Smith
        ASSIGNMENT:        Exercise 4-22 page 112
        DUE DATE:          Feburary 1999
        PURPOSE:           The purpose of this program is to read two points on a line 
entered from
                                   the keyboard, and will loop untill eof. Also it 
will it will determine 
                                   whether the lines are parallel or whether they 
intersect, and if they 
                                   intersect whether they are perpendicular.  'E' is 
being used for testing, 
                                   there is no resone why I picked it. 


*/




#include <stdio.h>
#include <stdlib.h>

#define PERP -1




int main()
{
        float x1, x2,
                  y1, y2;
float j;

        
        void print_user_instructions();
        float read_x1( float );
        float read_x2( float );
        float read_y1( float );
        float read_y2( float );
        
        print_user_instructions();       
        
        if ( ( j = read_x1( x1 ) ) == 'E' );
                return EXIT_FAILURE;
        
        if ( ( j = read_y1( y1 ) ) == 'E' );
                return EXIT_FAILURE;

        if ( ( j = read_x2( x2 ) ) == 'E' );
                return EXIT_FAILURE;

        if ( ( j = read_y2( y2 ) ) == 'E' );
                return EXIT_FAILURE;

}




/*      FUNCTION: print_user_instructions
        INPUT:    none
        OUTPUT:   none
        USE:      prints out the user instrutions to the screen
*/

void print_user_instructions()
{
        printf( "\nEnter 4 points for a line (1 point a time) to" 
                        "be tested for: parallel, perpendicular, or if" 
                        "they intersect.  To exit the program press eof," 
                        "(ex. ctrl z for DOS) or type quit at any time.\n" );
}




/*      FUNTION: read_x1
        INPUT:   prompt user for x1 
        OUTPUT:  returns the values of x1 for cords
        USE:     reads x1

*/

float read_x1( float x1 )

{
 
        printf( "\nenter x1: " );
        
        if      ( scanf( "%f" , &x1 ) != 1 )
        {
                printf( "\nFailed to read entered value\n" );
                x1 = 'E';       
                return x1;
        } 
                
return x1;
        
}





/*      FUNTION: read_x2
        INPUT:   prompt user for x2 
        OUTPUT:  returns the values of x2 for cords
        USE:     reads x2

*/

float read_x2( float x2 )

{
 
        printf( "\nenter x2: " );
        
        if      ( scanf( "%f" , &x2 ) != 1 )
        {
                printf( "\nFailed to read entered number\n" );
                x2 = 'E';
                return x2;
        }
        
return x2;
}




/*      FUNTION: read_y1
        INPUT:   prompt user for y1 
        OUTPUT:  returns the values of y1 for cords
        USE:     reads y1

*/

float read_y1( float y1 )

{
 
        printf( "\nenter y1: " );
        
        if      ( scanf( "%f" , &y1 ) != 1 )
        {
                printf( "\nFailed to read entered number\n" );
                y1 = 'E';
                return y1;
        }
        
return y1;
}






/*      FUNTION: read_y2
        INPUT:   prompt user for y2 
        OUTPUT:  returns the values of y2 for cords
        USE:     reads y2

*/

float read_y2( float y2 )

{
 
        printf( "\nenter y2: " );
        
        if      ( scanf( "%f" , &y2 ) != 1 )
        {
                printf( "\nFailed to read entered number\n" );
                y2 = 'E';
                return y2;
        }
        
return y2;
}


Reply via email to