File:  [CSRG BSD Unix] / 43BSDReno / share / doc / ps1 / 04.pascal / bigger7.p
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:57 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43reno
BSD 4.3reno

(*
 * Graphic representation of a function
 *    f(x) = exp(-x) * sin(2 * pi * x)
 *)
program graph1(output);
const
	d = 0.0625;   (* 1/16, 16 lines for interval [x, x+1] *)
	s = 32;       (* 32 character width for interval [x, x+1] *)
	h = 34;       (* Character position of x-axis *)
	c = 6.28138;  (* 2 * pi *)
	lim = 32;
var
	x, y: real;
	i, n: integer;
begin
	for i := 0 to lim do begin
		x := d * i;
		y := exp(-x) * sin(c * x);
		n := round(s * y) + h;
		repeat
			write(' ');
			n := n - 1
		until n = 0;
		writeln('*')
	end
end.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.