Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help complete this program to determine the direction made by points in a quadra

ID: 3870301 • Letter: H

Question

Help complete this program to determine the direction made by points in a quadrant:

#include #include int kindofturn( int x1, int y1, int x2, int y2, int x3, int y3 )

{

Your code

}

int main( int argc, char *argv[] )

{

int x1, y1, x2, y2, x3, y3, turn ;

x1 = atoi( argv[1] ) ;

y1 = atoi( argv[2] ) ;

x2 = atoi( argv[3] ) ;

y2 = atoi( argv[4] ) ;

x3 = atoi( argv[5] ) ;

y3 = atoi( argv[6] ) ;

turn = kindofturn( x1, y1, x2, y2, x3, y3 ) ;

if ( turn == 0 )

printf( " The points make a straight line. " ) ;

if ( turn < 0 ) printf( " The points make a right turn " ) ;

if ( turn > 0 ) printf( " The points make a left turn. " ) ;

printf( " " );

return 0 ;

}

Explanation / Answer

#include<stdio.h>
#include <stdlib.h>
int kindofturn( int x1, int y1, int x2, int y2, int x3, int y3 )
{

return (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);


}

int main( int argc, char *argv[] )

{

int x1, y1, x2, y2, x3, y3, turn ;

x1 = atoi( argv[1] ) ;

y1 = atoi( argv[2] ) ;

x2 = atoi( argv[3] ) ;

y2 = atoi( argv[4] ) ;

x3 = atoi( argv[5] ) ;

y3 = atoi( argv[6] ) ;


turn = kindofturn( x1, y1, x2, y2, x3, y3 ) ;


if ( turn == 0 )

printf( " The points make a straight line. " ) ;

if ( turn < 0 ) printf( " The points make a right turn " ) ;

if ( turn > 0 ) printf( " The points make a left turn. " ) ;

printf( " " );

return 0 ;

}