Site hosted by Angelfire.com: Build your free website today!

Pascal Assignment.

O..k.. here goes


PROGRAM ONE

Determine the output of the following program 

	program  function_time (input, output);
	const    maxsize = 80;
	type     line = packed array[1..maxsize] of char;

	function COUNTLETTERS ( words : line) : integer; {returns an integer}
	var      loop_count : integer;                   {local variable}
	begin
	      loop_count := 1;
	      while (words[loop_count] <> '.') and (loop_count <= maxsize) do
		      loop_count := loop_count + 1;
	      COUNTLETTERS := loop_count - 1
	end;

	var   oneline : line;
	      letters : integer;
	begin
	      writeln('Please enter in a sentence terminated with a .');
	      readln( oneline );
	      letters := COUNTLETTERS( oneline );
	      writeln('There are ',letters,' letters in that sentence.')
	end.




PROGRAM TWO

Write a program to calculate the cube of a given number (answer = number*number*number). Use a 
function to calculate the cube. 


PROGRAM THREE

Use function to write a program tha calculate the power of number1 to the power of number2, where 
number1 and number2 are two integer numbers input.
   The answer should be stored on a variable result and output on the screen.


PROGRAM FOUR

program ARRAY_TEST (output);
	var     numbers : ARRAY [1..5] of integer;
	begin
	     numbers[1] := 7;
	     numbers[2] := 13;
	     numbers[3] := numbers[2] - 1;
	     numbers[4] := numbers[3] DIV 3;
	     numbers[5] := numbers[3] DIV numbers[4];
	     for loop := 1 to 5 do
	        writeln('Numbers[',loop,'] is', numbers[loop] )
	end.


PROGRAM FIVE

Given the following marks achieved in a programming test, and that the pass mark is the average of all 
the marks, write a program to list those students who have passed. 
 FRED		21	GEORGE		56
 ANNE		52	MARY		89
 ROBERT		71	ALFRED		71
 CECIL		33	MIKE		54
 JENNIFER  	41	PAULINE		48



 

 

 

 

Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6 Lesson 7 Lesson 8

PASCAL Assignment.