hw1 - Class Quiz Results Code fragment 1: program...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Class Quiz Results Code fragment 1: program fac(input, output) var i, n, f : integer; begin readln(n); f := 1; for i := 1 to n do f := f * i; writeln(f) end. Pascal: 8 Ada: 6 Prolog: 5 Fortran77/90: 4 Lisp: 4 Cobol 3 Algol: 2 Haskell: 2 Basic: 1 C: 1 PL/I: 1 the correct answer Code fragment 2: PROGRAM FAC READ (*,*) N K=1 DO 100 I = 1, N K = K*I 100 CONTINUE WRITE (*, *) K END Fortran77/90: 18 Basic: 9 Cobol: 4 Algol60: 3 Haskell: 2 Ada: 1 Pascal: 1 Smalltalk80: 1 the correct answer Code fragment 3: fac 1 = 0 fac n = n * fac (n-1) C: 6 Smalltalk80: 6 Fortran77/90: 5 Lisp: 5 Haskell: 3 Pascal: 3 Basic: 2 Cobol: 2 Prolog: 2 Ada: 1 C++: 1 the correct answer Code fragment 4: FAC: PROCEDURE OPTIONS (MAIN); DECLARE (i, n, f) : FIXED; f = 1; GET n; DO i = 1 TO n; f = f * i; END; PUT f; END FAC; Pascal: 11 Basic: 8 Fortran77/90: 8 Cobol: 5 Haskell: 4 Ada: 1 Algol60: 1 Prolog: 1 PL/I: 0 the correct answer Code fragment 5: fac(1, 1). fac(N, F) :- N1 is N-1, fac(N1, F1), F is F*N. Lisp: 8 Prolog: 5 Ada: 5 Fortran77/90: 4 Pascal: 4 Haskell: 3 PL/I: 3 Algol60: 2 Basic: 2 Smalltalk80: 2 Cobol: 1 the correct answer Code fragment 6: (DEFINE (fac n) (COND ((= n 0) 1) (ELSE (* n (fac (- n 1)))) ) ) Lisp: 9 Prolog: 8 Haskell: 4 Pascal: 4 Algol60: 3 Ada: 2 C: 2 Cobol: 2 Fortran77/90: 1 PL/I: 1 the correct answer Code fragment 7: class Fac { public static void main(String args) throws IOException { DataInputStream in = new DataInputStream(System.in); int n = Integer.parseInt(in.readLine()); int i, f = 1; for (i = 1; i <= n; i++) f *= n; System.out.println(f); } } Java: 37 C++: 3 C: 1 PL/I :1 the correct answer ...
View Full Document

This note was uploaded on 11/13/2011 for the course COP 4020 taught by Professor Engelen during the Spring '11 term at FSU.

Page1 / 7

hw1 - Class Quiz Results Code fragment 1: program...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online