CLASS EXERCISE
What is displayed when the following program is executed?


	program IF_THEN_ELSE_TEST (output);
	var     a, b, c, d : integer;
	begin
	        a := 5;  b := 3;  c := 99;  d := 5;
	        if  a > 6  then  writeln('A');
	        if  a > b  then  writeln('B');
	        if  b = c  then
	        begin
	          writeln('C');
	          writeln('D')
	        end;
	        if  b <> c  then writeln('E') else writeln('F');
	        if  a >= c  then writeln('G') else writeln('H');
	        if  a <= d  then
	        begin
	          writeln('I');
	          writeln('J')
	        end
	end.

Click here for answer

PROGRAM FIVE
Calculate the gross pay for an employee. Input the rate of pay, hours worked and the service record in years. When the service record is greater than 10 years, an allowance of $15 is given. Verify that the program works by supplying appropiate test data.

Click here for answer

PROGRAM SIX
Write a program which inputs two values, call them A and B. Print the value of the largest variable.

Click here for answer

PROGRAM SEVEN
Modify the program you wrote for program six, to accept three values, A B C, and print the largest value.

Click here for answer


Copyright B Brown/P Henry/CIT, 1988-1997. All rights reserved.

1