Language: C

#include <stdio.h>

int main( void ) {
	int q;

	scanf( "%d", &q );
	while ( q-- ) {
		double x0, y0, x1, y1, x2, y2, x3, y3;
		double dn, nm, x, y;

		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3 );

		dn = ( x2 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y2 - y1 );
		nm = ( x3 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y3 - y1 );

		if ( fabs( dn ) < EPS ) {
			double h1 = x1 == x2 ? ( y3 - y1 ) / ( y2 - y1 ) : ( x3 - x1 ) / ( x2 - x1 );
			double h2 = x1 == x2 ? ( y4 - y1 ) / ( y2 - y1 ) : ( x4 - x1 ) / ( x2 - x1 );

			if ( ( h1 < h2 ? h1 : h2 ) < 0.0 && fabs( h1 < h2 ? h2 : h1 ) < EPS ) {
				*x = x1;
				*y = y1;
			} else if ( fabs( ( h1 < h2 ? h1 : h2 ) - 1.0 ) < EPS && 1.0 < ( h1 < h2 ? h2 : h1 ) ) {
				*x = x2;
				*y = y2;
			}
		} else {
			*x = x1 + nm / dn * ( x2 - x1 );
			*y = y1 + nm / dn * ( y2 - y1 );
		}

		printf( "%.8f %.8f\n", x, y );
	}

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:13:38: error: 'y4' undeclared (first use in this function); did you mean 'y'?
   13 |                 dn = ( x2 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y2 - y1 );
      |                                      ^~
      |                                      y
main.c:13:38: note: each undeclared identifier is reported only once for each function it appears in
main.c:13:52: error: 'x4' undeclared (first use in this function); did you mean 'x'?
   13 |                 dn = ( x2 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y2 - y1 );
      |                                                    ^~
      |                                                    x
main.c:16:22: error: implicit declaration of function 'fabs' [-Wimplicit-function-declaration]
   16 |                 if ( fabs( dn ) < EPS ) {
      |                      ^~~~
main.c:2:1: note: include '<math.h>' or provide a declaration of 'fabs'
    1 | #include <stdio.h>
  +++ |+#include <math.h>
    2 | 
main.c:16:22: warning: incompatible implicit declaration of built-in function 'fabs' [-Wbuiltin-declaration-mismatch]
   16 |                 if ( fabs( dn ) < EPS ) {
      |                      ^~~~
main.c:16:22: note: include '<math.h>' or provide a declaration of 'fabs'
main.c:16:35: error: 'EPS' undeclared (first use in this function)
   16 |                 if ( fabs( dn ) < EPS ) {
      |                                   ^~~
main.c:21:33: error: invalid type argument of unary '*' (have 'double')
   21 |                                 *x = x1;
      |                                 ^~
main.c:22:33: error: invalid type argument of unary '*' (have 'double')
   22 |                                 *y = y1;
      |                                 ^~
main.c:24:33: error: invalid type argument of unary '*' (have 'double')
   24 |                                 *x = x2;
      |                                 ^~
main.c:25:33: error: invalid type argument of unary '*' (have 'double')
   25 |                                 *y = y2;
      |                                 ^~
main.c:28:25: error: invalid type argument of unary '*' (have 'double')
   28 |                         *x = x1 + nm / dn * ( x2 - x1 );
      |                         ^~
main.c:29:25: error: invalid type argument of unary '*' (have 'double')
   29 |                         *y = y1 + nm / dn * ( y2 - y1 );
      |                         ^~