7

Type shortreal

The Pascal function,

RetShortReal.p

The C++ main program,

RetShortRealMain.cc

function RetShortReal (r: shortreal): shortreal;

begin

RetShortReal := r + 1.0 end;

#include <stdio.h> #include <math.h>

extern "C" float RetShortReal (float);

int main(void)

{

float r, s; r = 2.0;

s = RetShortReal(r);

printf (" %8.6f \n", s);

}

The commands to compile and execute RetShortReal.p and RetRealMain.cc

hostname% pc -c RetShortReal.p

hostname% CC RetShortReal.o RetShortRealMain.cc -lpchostname% a.out

3.000000

The Pascal function, IO.p

Input and Output

procedure IO;

begin

writeln ('Hello, Pascal & St.Petersburg !'); end;

154

Pascal 4.0 User’s Guide

Page 178
Image 178
HP SunSoft Pascal 4.0 manual Input and Output, Hostname% pc -c RetShortReal.p, Pascal function, IO.p, 154