
SELF TEST: ANSWERS
1. Which of the following Pascal functions which change the value 6.6 to an integer value of 7
odd
round
trunc
abs
2. Which of the following Pascal operators has the least priority
=
+
/
NOT
3. Write a simple Pascal procedure called Welcome which prints the text string "Welcome to Pascal"
procedure Welcome;
begin
writeln('Welcome to Pascal')
end;
4. Write a Pascal procedure called Multiply, which accepts two
integers, number1 and number2, and prints the result of
multiplying the two integers together.
procedure Multiply( number1, number2 : integer ); var Result : integer; begin Result := number1 * number2; writeln( Result ) end;5. What is the output of the following Pascal program
program Sample( output );
var x, y : integer;
procedure godoit( x, y : integer );
begin
x := y; y := 0;
writeln( x, y );
end;
begin
x := 1; y := 2;
godoit( x, y );
writeln( x, y )
end.
Program Output
2 0
1 2
6. Write a Pascal function called Multiply2 which returns an
integer result. The function accepts two integer parameters, number1
and number2 and returns the value of multiplying the two parameters
function Multiply2( number1, number2 : integer ) : integer; var Result : integer; begin Result := number1 * number2; Multiply2 := Result end;
