Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out

sheet Course title Structure of programming language

VIEWS: 2 PAGES: 3

Structure of Programming Languages lecture

More Info
									              Course title : Structure of programming language
              Course code : CS 212
              Instructors : Dr. Yasser Fouad
                             Sheet # Introduction
   1. Judging from the history of programming languages what do you think is most
      important to make a language successful?
   2. Assume a language allows a function or procedure to return results of some
      types but not all types (like in C where arrays cannot be returned). What principle
      is violated? What are the advantages of the principle mentioned above? Could
      there be disadvantages if it was overused in language design?
   3. What are the arguments for and against the idea of a typeless programming
      language?
   4. Many languages have been designed by a single individual, others by committee.
      What's the best approach? Use historical examples to support your argument.
   5. Choose any language you are familiar with and briefly describe three positive
      aspects and three negative aspects of the language design. In other words, what
      did the designers do right and what did they do wrong?
   6. Test your Language Knowledge.
Choose from these languages which code belongs to:
ADA
ALGOL 60
BASIC
C
C++
COBOL
FORTRAN 77
FORTRAN 90
HASKELL
JAVA
LISP
PASCAL
PL/I
PROLOG
SMALLTALK-80

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.

Code fragment 2:
PROGRAM FAC
READ (*,*) N
K=1
DO 100 I = 1, N
K = K*I
100 CONTINUE
WRITE (*, *) K
END

Code fragment 3:
fac 1 = 0
fac n = n * fac (n-1)
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;

Code fragment 5:
fac(1, 1).
fac(N, F) :- N1 is N-1, fac(N1, F1), F is F*N.

Code fragment 6:
(DEFINE (fac n)
(COND
((= n 0) 1)
(ELSE (* n (fac (- n 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);
}
          }

								
To top