{$SYMTAB-}
PROGRAM COMPLEX (INPUT,OUTPUT);

CONST
    PI = 3.141592653589793;

TYPE
    COMPLEX = ARRAY [1..2] OF REAL;
VAR
    W,X,Y,Z : COMPLEX;
    M,N : INTEGER;

FUNCTION CADD(X,Y:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CSUB(X,Y:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CMUL(X,Y:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CDIV(X,Y:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CINV(X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CNPOWR(N:INTEGER;X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CNROOT(N:INTEGER;X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CSQRT(X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CEXP(X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CLN(X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CLOGXY(X,Y:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CYX(X,Y:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CSIN(X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CCOS(X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CTAN(X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CARCSIN(X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CARCCOS(X:COMPLEX) : COMPLEX; EXTERN;

FUNCTION CARCTAN(X:COMPLEX) : COMPLEX; EXTERN;

BEGIN
    WRITELN;
    WRITE('What are the complex X values? ');
    READLN(X[1],X[2]);
    WRITE('What are the complex Y values? ');
    READLN(Y[1],Y[2]);
    WRITE('What is the integer N value?   ');
    READLN(N);
    M := -N;
    WRITELN;  WRITELN;  WRITELN;
    WRITELN('COMPLEX FUNCTIONS TEST':40);
    WRITELN;

    WRITELN('   X REAL      X COMPLEX      Y REAL     Y COMPLEX     N');
    WRITELN(X[1]:10:5,X[2]:15:5,Y[1]:12:5,Y[2]:14:5,N:6);
    WRITELN;

    Z := CADD(X,Y);
    WRITELN('X + Y =              ',Z[1]:12:5,Z[2]:12:5);

    Z := CSUB(X,Y);
    WRITELN('X - Y =              ',Z[1]:12:5,Z[2]:12:5);

    Z := CMUL(X,Y);
    WRITELN('X * Y =              ',Z[1]:12:5,Z[2]:12:5);

    Z := CDIV(X,Y);
    WRITELN('X / Y =              ',Z[1]:12:5,Z[2]:12:5);

    Z := CNPOWR(N,X);
    W := CNPOWR(M,X);
    WRITELN('X TO THE N POWER  =  ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CNROOT(N,Z);
    W := CNROOT(M,W);
    WRITELN('N ROOT OF X =        ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CSQRT(X);
    M := 2;
    W := CNPOWR(M,Z);
    WRITELN('SQUARE ROOT OF X =   ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CEXP(X);
    W := CLN(Z);
    WRITELN('E TO THE X POWER =   ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    W[1] := -X[1];
    W[2] := -X[2];
    Z := CEXP(W);
    W := CLN(Z);
    WRITELN('E TO THE -X POWER =  ',Z[1]:12:5,Z[2]:12:5,-W[1]:15:5,-W[2]:12:5);

    Z := CLN(X);
    W := CEXP(Z);
    WRITELN('COMPLEX LN(X) =      ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CLOGXY(X,Y);
    W := CYX(Z,Y);
    WRITELN('LOG OF X BASE Y =    ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CYX(X,Y);
    W := CLOGXY(Z,Y);
    WRITELN('Y TO THE X POWER =   ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CSIN(X);
    W := CARCSIN(Z);
    WRITELN('COMPLEX SIN(X) =     ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CCOS(X);
    W := CARCCOS(Z);
    WRITELN('COMPLEX COS(X) =     ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CTAN(X);
    W := CARCTAN(Z);
    WRITELN('COMPLEX TAN(X) =     ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CARCSIN(X);
    W := CSIN(Z);
    WRITELN('COMPLEX ARCSIN(X) =  ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CARCCOS(X);
    W := CCOS(Z);
    WRITELN('COMPLEX ARCCOS(X) =  ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

    Z := CARCTAN(X);
    W := CTAN(Z);
    WRITELN('COMPLEX ARCTAN(X) =  ',Z[1]:12:5,Z[2]:12:5,W[1]:15:5,W[2]:12:5);

END.
