• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Principles of Programming Languages

Question 11

The following program fragment is written in a programming language that allows variables and does not allow nested declarations of functions. C
global int i = 100, j = 5;
void P(x)
{
    int i = 10;
    print(x + 10);
    i = 200;
    j = 20;
    print(x);
}
main()
{
    P(i + j);
}
If the programming language uses static scoping and call by need parameter passing mechanism, the values printed by the above program are
  • 115, 220
  • 25, 220
  • 25, 15
  • 115, 105

Question 12

The following program fragment is written in a programming language that allows variables and does not allow nested declarations of functions. C
global int i = 100, j = 5;
void P(x)
{
    int i = 10;
    print(x + 10);
    i = 200;
    j = 20;
    print(x);
}
main()
{
    P(i + j);
}
If the programming language uses dynamic scoping and call by name parameter passing mechanism, the values printed by the above program are :
  • 115, 220
  • 25, 220
  • 25, 15
  • 115, 105

Question 13

The results returned by functions under value-result and reference parameter passing conventions
  • Do not differ
  • Differ in the presence of loops
  • Differ in all cases
  • May differ in the presence of exceptions

Question 14

What is printed by the print statements in the program P1 assuming call by reference parameter passing?
Program P1()
{
   x = 10;
   y = 3;
   func1(y,x,x);
   print x;
   print y;
}
func1(x,y,z)
{
   y = y+4;
   z = x+y+z;
}
  • 10, 3
  • 31, 3
  • 27, 7
  • None of the above

Question 15

Consider the following program pascal
Program P2 
    var n: int: 
     procedure W(var x: int) 
     begin 
         x=x+1; 
         print x;   
     end 

     procedure D 
     begin  
         var n: int; 
         n=3; 
         W(n);  
     end 
begin //beginP2 
  n=10; 
  D; 
end 
If the language has dynamic scoping and parameters are passed by reference, what will be printed by the program?
  • 10
  • 11
  • 3
  • None of the above

Question 16

Aliasing in the context of programming languages refers to
  • multiple variables having the same memory location
  • multiple variables having the same value
  • multiple variables having the same identifier
  • multiple uses of the same variable

Question 17

What will be the output of the following pseudo-code when parameters are passed by reference and dynamic scoping is assumed?
a=3;
void n(x) {x = x * a; print(x);}
void m(y) {a = 1; a = y - a; n(a); print(a);}
void main() {m(a);} 
  • 6, 2
  • 6, 6
  • 4, 2
  • 4, 4

Question 18

The attributes of three arithmetic operators in some programming language are given below.

Operator  Precedence   Associativity     Arity
+           High         Left            Binary
-           Medium       Right           Binary 
*           Low          Left            Binary 
The value of the expression 2 - 5 + 1 - 7 * 3 in this language is __________ ?   Note : This question was asked as Numerical Answer Type.
  • 1
  • 2
  • 3
  • 9

Question 19

Match the programming paradigms and languages given in the following table.
2008_13
  • I-c, II-d, III-b, IV-a
  • I-a, II-d, III-c, IV-b
  • I-d, II-c, III-b, IV-a
  • I-c, II-d, III-a, IV-b

Question 20

Which formal system provides the semantic foundation for Prolog?
  • Predicate calculus
  • Lambda calculus
  • Hoare logic
  • Propositional logic

There are 35 questions to complete.

Last Updated :
Take a part in the ongoing discussion