Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

KATHMANDU UNIVERSITY Marks Scored:

End Semester Examination


2013
Level : B. E./B. Sc. Course : COMP 301
Year : III Semester : I

Exam Roll No. : Time: 30 mins. F. M. : 10


Date :
Registration No.:

SECTION “A”
[20 Q 0.5 = 10]
Choose the most appropriate answer.
1. Orthogonality, syntax design, support of abstraction and exception handling are related with
__________ .
[ ] Readability [ ] Writability [ ] Reliability [ ] All given options

2. Grace Hopper at UNIVAC developed a series of compiling system named


[ ] A-0, A-1, and A-3 [ ] C-0, C-1, and C-3 [ ] G-0, G-1, and G-2 [ ] U-0, U-1, and U-3

3. Which of the following statements about the current standard Java implementation for Java is
not true?
[ ] It contains a compiler (javac) that translates Java source code to Java bytecode.
[ ] It implements Java using a pure compiler.
[ ] The virtual machine for executing Java bytecode (java) uses a bytecode interpreter.
[ ] The virtual machine for executing Java bytecode (java) uses a just-in-time compiler.

4. One key advantage of compilation over interpretation is that .


[ ] compiled code can more easily accommodate dynamic loading of new source code.
[ ] compiled code can more easily accommodate type free variables.
[ ] compiled code is machine-independent.
[ ] compiled code will usually run faster.

5. Backus-Naur Form (BNF) is a notation for __________________.


[ ] context-free grammars [ ] context-sensitive grammars
[ ] unrestricted grammars [ ] all of the above

6. Shift reduce parsing method .


[ ] uses LL parsing algorithm.
[ ] corresponds to left derivation of grammar.
[ ] corresponds to right derivation of grammars.
[ ] corresponds to reverse of right derivation of grammar

7. EBNF for <expr> ::= <expr> + <term> would be


[ ] <expr> ::= {<expr> +} <term> [ ] <expr> ::= <expr> {+ <expr>}
[ ] <expr> ::= <term> {+ <term>} [ ] <expr> ::= +{<term>}

8. Which one is not the attribute of a variable?


[ ] scope [ ] binding [ ] name [ ] value
9. State diagrams of the form used for lexical analyzers are representations of a class of
mathematical called .
[ ] Turing machine
[ ] Linear-bounded non-deterministic Turing machine
[ ] Non-deterministic pushdown automaton
[ ] Finite state automaton

10. Consider the following operation. What will be the resultant data type0000?
(float)a * (int)b / (long)c * (double)d
[ ] int [ ] long [ ] float [ ] double

11. Which variable has the longest scope?


#include <stdio.h>
int b;
int main()
{
int c;
return 0;
}
int a;
[ ]a [ ]b [ ]c [ ] both (a) and (b)

12. Whenever a new value is placed in a memory location, that value overrides the previous
value in that location. This process is said to be
[ ] destructive [ ] constructive [ ] nondestructive [ ] value overriding

13. Artificial Intelligence is a broad area of computer application characterized by the use of
rather than computation.
[ ] function, symbol [ ] symbol, numeric [ ] numeric, function [ ] numeric, symbol

14. was later transfer to a UNIVAC I computer.


[ ] Pseudocode [ ] FORTRAN [ ] LISP [ ] short code

15. ML stands for .


[ ] Milnear Language [ ] Meta Language
[ ] Mathematics Language [ ] Mechanics Language

16. An attribute grammar is a device used to describe more of the structure of a programming
language than can be describe with a .
[ ] Recursively enumerable [ ] Context-sensitive
[ ] Context-free [ ] Regular

17. allows elliptical references to record fields.


[ ] LISP [ ] FORTRAN [ ]C [ ] COBOL

18. Which of the following is not a semantic model?


[ ] in mode [ ] out mode [ ] inout mode [ ] outin mode

19. A is the collection of the attribute of a variable.


[ ] primitive [ ] descriptor [ ] precision [ ] enumeration

20. Type checking is directly related with .


[ ] compatibility [ ] coercion [ ] concord [ ] communion
KATHMANDU UNIVERSITY
End Semester Examination
2013
Level : B. E./B. Sc. Course : COMP 301
Year : III Semester : I
Time : 2 hrs 30 minutes F.M. : 40
_____________________________________________________________________________
SECTION “B”
[6 Q.  4= 24 marks]

Attempt any SIX questions:

1. Provide your strong arguments on the idea of “single language for all programming domain”?
Many languages treat identifiers of uppercase letters and lowercase letters differently. What
are the pros and cons of this design decision?
2. Prove that the following grammar is ambiguous:
S A
A  A + A | <id>
<id>  a | b | c
3. Covert the given FSA into regular expression

Design a state diagram to recognize one form of the comment of the C-based programming
languages, those that begin with /* and end with */.

4. Consider the following C program snippet:


void fun (void){
int a, b, c; /* definition 1 */
...
while(...){
int b, c, d; /* definition 2 */
... 1
while(...){
int c, d, e; /* definition 3 */
... 2
}
... 3
}
... 4
}
a) For each of the four marked points (1, 2, 3, and 4) in fun function, list each visible
variable along with the number of the definition statement that defines it.
b) What are the design issues for the names?
5. How do the functions malloc and free make C language more flexible? Explain tombstone
methods of avoiding dangling pointers.

6. What do you mean by pairwise disjoint test? Explain with suitable example. What is
difference between l-value and r-value of a variable?

7. How is stack dynamic variable different from heap dynamic variable? What do you mean by
coroutine? Where is it mainly used?

SECTION “C”
[2 Q. 8 = 16 marks]
Attempt any TWO questions:
8. Consider the following grammar and parse table. Show a complete parse, including the parse
stack contents, input string, and action for the string (id+id)+id.
Grammar:
1. E E+T
2. E T
3. T T*F
4. T F
5. F  (E)
6. F id

Figure 1 Parse Table

9. Let the function fun be defined as


int fun(int *k){
*k += 4;
return 3 * (*k) -1 ;
}
Suppose fun is used in a program as follows:

void main( ){
int i = 10, j = 10, sum1, sum2;
sum1 = (i/2) + fun (&i);
sum2 = fun(&j) + (j/2);
}
a) What will be the values of sum1 and sum2 if
i. operands in the expressions are evaluated left to right?
ii. operands in the expression are evaluated right to left?
b) Define the side effect of a function? What is coercion? Define narrowing and widening
conversions. What is short-circuit evaluation?
10. Explain in detail about parameter passing methods for sub-programs. Consider the following
program written in C:
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 the values of a variable value
after each call to swap function?
a. Pass by Value
b. Pass by Reference
c. Pass by Value-Result
Objective Answers

1. Reliability
2. A-0, A-1, and A-3
3. It implements Java using a pure compiler.
4. compiled code will usually run faster.
5. context-free grammars
6. corresponds to reverse of right derivation of grammar
7. <expr> ::= <term> {+ <term>}
8. binding
9. Finite state automaton
10. double
11. b
12. destructive
13. symbol, numeric
14. short code
15. Meta Language
16. Context-free
17. COBOL
18. outin mode
19. descriptor
20. compatibility

You might also like