Question 8492 – Operator
February 1, 2024Compiler-Design
February 1, 2024Programming
Question 10
|
(a) Consider the following Pascal function where A and B are non-zero positive integers. What is the value of GET(3,2)?
function GET(A,B:integer);integer; begin if B = 0 then GET:=1 else if A < B then GET:=0 else GET:=GET(A-1,B)+GET(A-1,B-1) end ;
(b) The Pascal procedure given for computing the transpose of an N × N (N>1) matrix A of integers has an error. Find the error and correct it.
Assume that the following declaration are made in the main program
const MAXSIZE=20; type INTARR=array [1.,MAXSIZE,1..MAXSIZE] of integer; Procedure TRANSPOSE (var A: INTARR; N : integer); var I, J, TMP, integer; begin for I:=1 to NO – 1 do for J:=1 to N do begin TMP: = A[I,J]; A[I,J]:=A[J,I]; A(J,I):=TMP end end;
Theory Explanation.
|
Correct Answer: A
Subscribe
Login
0 Comments