hw1 - fac(1, 1). fac(N, F) :- N1 is N-1, fac(N1, F1), F is...

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

View Full Document Right Arrow Icon
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 the correct answer Ada: 6 Prolog: 5 Fortran77/90: 4 Lisp: 4 Cobol 3 Algol: 2 Haskell: 2 Basic: 1 C: 1 PL/I: 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
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 the correct answer Basic: 9 Cobol: 4 Algol60: 3 Haskell: 2 Ada: 1 Pascal: 1 Smalltalk80: 1
Background image of page 2
Code fragment 3: fac 1 = 0 fac n = n * fac (n-1) C: 6 Smalltalk80: 6 Fortran77/90: 5 Lisp: 5 Haskell: 3 the correct answer Pascal: 3 Basic: 2 Cobol: 2 Prolog: 2 Ada: 1 C++: 1
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
Code fragment 5:
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fac(1, 1). fac(N, F) :- N1 is N-1, fac(N1, F1), F is F*N. Lisp: 8 Prolog: 5 the correct answer Ada: 5 Fortran77/90: 4 Pascal: 4 Haskell: 3 PL/I: 3 Algol60: 2 Basic: 2 Smalltalk80: 2 Cobol: 1 Code fragment 6: (DEFINE (fac n) (COND ((= n 0) 1) (ELSE (* n (fac (- n 1)))) ) ) Lisp: 9 the correct answer Prolog: 8 Haskell: 4 Pascal: 4 Algol60: 3 Ada: 2 C: 2 Cobol: 2 Fortran77/90: 1 PL/I: 1 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 the correct answer C++: 3 C: 1 PL/I :1...
View Full Document

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

Page1 / 7

hw1 - fac(1, 1). fac(N, F) :- N1 is N-1, fac(N1, F1), F is...

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