Winnie Leung F.4CA (22) Question Paper Computer Test (I) (23/3/2000) Show your rough work on the spaces by the questions. 1. In order to extract a sub-string of string s from the i-th position to the last, the corresponding statement is A. copy(s, i, length(s)) B. copy(s, i, length(s) - 1) C. copy(s, i, length(s) - i) D. copy(s, i, length(s) - i + 1) E. copy(s, i, length(s) - i - 1) Ans : ____________________________ 2. Which of the following conditions is/are true? (1) 'ABC' = 'ABC ' (2) 'ABC' < 'abc' (3) '32' < '123' Ans : _______________________ 3. What is the output when the following program segment is executed? var a, b : string; ...... a := '1234'; b := '789'; writeln(a + b); Ans : _______________________ 4. What is the output of the following program segment? var a : string; b, i : integer; ...... a := '123'; b := 0; for i :=1 to 2 do begin a := a + '45'; b := b + length(a) + i; end; writeln(b); Ans : ___________________________ 5. var a, b : integer; ....... a := 'ROMRAMROM'; b := copy(a, 5, 5); writeln(ord(b[1]); What is the output of the above Pascal program segment? Ans : _________________________ 6. var a : string; i : integer; ..... a := 'ABCDE'; for i := 5 downto 1 do a[i] := chr(ord(a[i])) +15); writeln(a); What is the output of the above program ? Ans : _________________________ 7. var a : string; k : integer; ........... a := 'COMPUTER'; k := length(a); for i := 1 to k do a := a[2*i - 1] + a; writeln(copy(a, 1, k)); What is the output of the above Pascal program segment? Ans : _____________________________ 8. var x, y : string; k, s : integer; ....... x := 'COMPUTER'; y := 'LANGUAGE'; s := 0; for k := 1 to 8 do if copy(x, k, 1) > copy(y, 9-k, 1) then s := s + 1; writeln(s); What is the output of the above program segment? Ans. : ______________________________ 9. How many times will the following loop be executed? var b : integer; ....... b :=0; while b<=8 do b := b + 2; Ans : ____________________________ 10. Which of the following comparisions give(s) the result true? (1) 0 > -3 or -5<-7 (2) 'k' > 'K' and 'a' > '9' (3) 'A' > '8' Ans : ___________________________