The following program plots a real-valued function f (X) by letting the X-axis run vertically and then writing an asterisk in positions corresponding to the coordinates. The position of the asterisk is obtained by computing Y = f (X), multiplying by a scale factor, rounding the product to the next integer, and then adding a constant and letting the asterisk be preceded by that many blank spaces. 

program Graph1(Output); { Program 4.7 - Generate graphic representation of the function: f(X) = exp(-X) * sin(2*Pi*X) const XLines = 16 { line spacings per 1 abscissa unit }; Scale = 32 { character widths per 1 ordinate unit}; ZeroY = 34 {character position of X axis }; XLimit = 32 { length of graph in lines }; var Delta: Real TwoPi: Real X, Y : Real; increment along abscissa }; 2 * Pi = 8 * ArcTan(1.0) }; Point: Integer; YPosition: Integer; begin {initialize constants: Delta := 1 / Xlines; TwoPi := 8 * ArcTan(1.0); for Point := 0 to XLimlt do end begin X := Delta * Point.: Y := Exp(-X) * Sin(TwoPi * X); YPosition := Round(Scale * Y) + ZeroY; repeat Write (Output, ' '); YPosition:= YPosition - 1 until YPosition = J; Writeln(Output, '*') end 

