CS508- Modern Programming Languages| CS508 past paper 2023 | CS508 PAST papers | CS508

Q.No.1 Write three concepts which are introduced in LISP first time?

Answer: • Conditionals: such as if-then-else construct. • Function types: where functions are just like integers and strings • Recursion: first language to support it. • Dynamic typing: all variable are pointers. • Garbage-Collection. • Programs composed of expressions. • A symbol type. • The whole program is a mathematical function

Q.No.2 Write a function in LISP to concatenate two lists List a=(3 4 5) List b=(c d 6)

Answer: >(append ‘(3 4 5) ‘(c d 6)) (3 4 5 c d 6)..concatenated List

 Q.No.3 Ada is strongly typed language describe how?

Answer: ADA is strongly typed. A programming language is strongly typed if type errors are always detected and in ADA Errors can be signaled as exceptions and handled explicitly. Many serious errors such as computational overflow and invalid array indexes are automatically caught and handled through this exception mechanism, improving program reliability.

Q.No.4 How can we determine the size of Array in SNOBOL?

Answer: In SNOBOL, The size of the array can be determined at run time by using input from the system of using a variable. Example: A = ARRAY(INPUT) Q.No.5 In C++ ^ and ~ are used for bitwise exclusive OR and bitwise NOT write there equivalent in ada Answer: ^ bitwise exclusive OR of c++ = Xor in ADA.. ~ = Not in ADA Q.No.6 What code in LISP language used to compute power of x to y?

Q.5. What is Defun Power?

 Answer: (defun power (x y) (if (= y 0) 1 (* x (power x (1- y))))) This function computes the power of x to y. That is, it computes xy by recursively multiplying x with itself y number of times. Example; >(power 3 4) 81

Q.No.6 A code was given about ADA case concept. Please refer topic “Case statement”?

 Answer: case expression is when choice list => sequence-of-statements when choice list => sequence-of-statements when others => sequence-of-statements end case;

Q.No.7 Name functions that are used in List construction

Answer: Lists can be created and extended with the help of three basic functions. 1) cons, 2) list 3) append

Q.No.9 Write IO header file for Ada.

Answer: with Ada.Text_Io; — intent to use use Ada.Text_Io; — direct visibility

 Q.No.10 What are operators for Logical AND && and Logical OR || used in ADA.

Answer: Logical AND &&= And in ADA Logical OR || = Or in ADA

Q.No.11 Features added in COBOL not included in SNOBOL.

 Answer: COBOL has introduced hierarchical data structures (records) and nested selection statements. The COBOL language supported long variable names (up to 30 characters) with hyphens, data division, and fixed-point arithmetic. These all feature in COBOL language are those which were added or enhanced and were not included in SNOBOL.

Q.No.12 What is the functionality of KEYWORD INT|CAHR IN snobol4?

Answer: In SNOBOL 4 Vertical bar is used to specify pattern alternation. KEYWORD INT|CAHR This statement assigns the pattern ‘INT’ | ‘CHAR’ to the variable KEYWORD. KEYWORD will now get a new value which is ‘INT’ | ‘CHAR’ So we can create new pattern by using the assignment statement.

 Q.No.13 Write two comparative operators used as function for numerical values in lisp programming language?

Answer: Comparative operators which are used as functions for numerical values are =, >, <, >=, <=;

Q.No.14 What is error in it >(sqrt x) in LISP?

Answer: This code generates an error as the symbol x is not associated with any value and thus cannot be evaluated. It will give error like this. Error: The variable X is unbound.

Q.No.15 How many element in it (a (d e)) related to lisp?

 Answer: There are two elements. Atom = a List = (d e)

Q.No.16 Which data structure map pairs of associated data object in snobol?

Answer: A table data structure maps pairs of associated data objects. Tables have varying lengths and are dynamically extended if necessary. T = TABLE()……If want to creates a table of unspecified length. T = TABLE(N)……..if want to creates a table that initially has room for N elements Once created, table can be used in a manner similar to arrays. The only difference is that they are indexed by the key value and not the index number. For example: T<‘A’> = 1 Associates key ‘A’ with value 1.

 Q.No.17 What is predicate in lisp language conform?

Answer: A predicate is a special function which returns NIL if the predicate is false, T or anything other than NIL, otherwise. Predicates are used to build Boolean expressions in the logical statements. Comparative operators in LISP used as functions for numerical values and return a T or NIL. =, >, <, >=, <=; For example 1: (= (+ 2 4) (* 2 3)) T example 2: (> (- 5 2) (+ 3 1)) NIL

 Q.No.18 Which language first provided exception handling among c++, ada?

Answer: Although PL/1 has introduce the concept of exception handling. But ADA has elaborated this concept. è Ada was the first language to provide a structured exception handling mechanism. è Ada includes an exception handling mechanism so that these problems can be dealt with at run-time. è Errors can be signaled as exceptions and handled explicitly. è Many serious errors such as computational overflow and invalid array indexes are automatically caught and handled through this exception mechanism, improving program reliability.

Q.No.19 Write a complete program in ada to print this out put by only using put_line command. Use the loop isn’t allowed. print this code * *** ***** *******

Answer: procedure Starprint is begin Put (“*”); New_Line ; Put (“***”); New_Line ; Put (“*****”); New_Line ; Put (“******”); New_Line ; end Starprint;

Q.No.20 Does ada believe in human programming if yes then why?

 Answer: Yes, ada believe in human programming .Programming as a human activity is the main goal of ADA. In ADA the whole philosophy is that a programmer is a human and all humans make mistakes. So to make it safer, Ada uses discriminates in a record that tells what type of data is currently stored there.

Leave a Comment