21CSV208 - Question Bank Principles of Programming Languages[1]
21CSV208 - Question Bank Principles of Programming Languages[1]
2
4. Write a grammar for the language consisting of strings that have n copies of the
letter a followed by the same number of copies of the letter b, where n>0.
a. For example, the strings ab, aaaabbbb, and aaaaaaaabbbbbbbb are in the
CO - App (16)
language but a, abb, ba, and aaabb are not.
b. Draw parse trees for the sentence aabb and aaaabbbb, as derived from the
grammar of the given question.
5. Explain about recursive-descent parsing. CO - U (16)
6. Explain Attribute Grammars with example. CO - U (16)
7. Given the following grammar and the right sentential form, draw a parse tree
and show the phrases and simple phrases, as well as the handle. S →
CO - App (16)
AbB|bAc A → Ab| aBB B → Ac| cBb|c
Acccbbc b. AbcaBccb c. baBcBbbc
8. Consider the following grammar for arithmetic expressions:
E→E+T|T
T→T*F|F
CO - App (16)
F → (E) | id
Find a Leftmost derivation and Rightmost derivation for the expression
id, id + id, id+id*id.
9. Describe the parsing problem for a top-down parser CO - U (16)
10. Describe the parsing problem for a bottom-up parser CO - U (16)
11. What is parsing, what are the difference types of parser available, discuss? CO - U (16)
12. Explain top-down parser with example. CO - U (16)
UNIT - II
1. Define static binding and dynamic binding CO - U (16)
2. Define fully qualified and elliptical references to fields in records. CO - U (16)
3. Explain Arithmetic expression? Explain with example Relational and Boolean CO - U (16)
Expressions.
4. Explain briefly about control Structures. CO - U (16)
5. Define lifetime, scope, static scope, and dynamic scope. CO - U (16)
6. Explain Records data type. CO - U (16)
7. Explain Expression in programming languages CO - U (16)
8. Explain about binding. CO - U (16)
9. Explain with examples for control structures. CO - U (16)
10. What are the different types of binding available, explain with an example? CO - U (16)
11. What is meant by data type? What is the various Primitive Data type? Evaluate CO - U (16)
the various data types
12. Explain Overloaded Operators. CO - U (16)
UNIT - III
1. Explain the types of parameter passing methods. CO - U (16)
2. Write short notes on recursion to compute the factorial function. CO - U (16)
3. Brief the design issues for functions? CO - U (16)
4. Explain about Parameter Passing methods. CO - U (16)
3
5. Consider the following program written in C syntax: CO - App (16)
void swap(int a, int b)
{ int temp;
temp = a;
a = b;
b = temp;
}
void main()
{ int value = 2, list[5] = {1, 3, 5, 7, 9};
swap(value, list[0]);
swap(list[0], list[1]);
swap(value, list[value]);
}
For each of the following parameter-passing methods, what are all of the values
of the variables value and list after each of the three calls to swap?
a. Passed by value
b. Passed by reference
c. Passed by value-result
6. Present one argument against providing both static and dynamic local variables CO - U (16)
in subprograms.
7. Show the stack with all activation record instances, including the dynamic chain, CO - App (16)
when execution reaches position 1 in the following skeletal program. This
program uses the deep-access method to implement dynamic scoping.
void fun1() {
float a;
…
}
void fun2() {
int b,c;
…
}
void fun3() {
float d;
…
}
void main() {
char e, f, g;
…
}
4
The calling sequence for this program for execution to reach fun3 is
main calls fun2
fun2 calls fun1
fun1 calls fun1
fun1 calls fun3
8. Explain about the types of Dynamic Scoping. CO - U (16)
9. Show the stack with all activation record instances, including static and dynamic CO - App (16)
chains, when execution reaches position 1 in the following skeletal program.
Assume Bigsub is at level 1.
Procedure Bigsub is
Procedure A is
Procedure B is
begin—of B
….l
end;-- of B
procedure Cis
begin — of C
…
B;
…
end; -- of C
begin — of A
…
C;
…
end; -- of A
begin — of Bigsub
…
A;
…
End;--of Bigsub
6
UNIT - V
1. Explain the fundamentals of programming languages CO - U (16)
2. Differentiate functional programming and object oriented programming CO - U (16)
3. Write the factorial function by using ML CO - App (16)
4. Explain about LISP functional programming language CO - U (16)
5. Explain list structures and Goal statements in PROLOG. CO - U (16)
6. Write differences between procedural and non-procedural languages CO - U (16)
7. Discuss about basic elements of prolog. Give examples. CO - U (16)
8. Write a prolog description of your family tree (based only on facts), going back CO - App (16)
to your grandparents and including all descendants. Be sure to include all
relationships.
9. Discuss about basic elements of prolog. Give examples. CO - U (16)
10. Briefly explain application logic programming. CO - U (16)
11. How ML is different from other functional programming languages? CO - U (16)
12. How PROLOG is different from other logic programming languages? Give an CO - U (16)
example for each feature