You are on page 1of 5

KATHMANDU UNIVERSITY Mark scored:

End Semester Examination[C]


2014
Level : B.E.\B.Sc. Course : COMP 301
Year : III Semester : I

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

Registration No.: Date :

SECTION “A”
[20 Q.  0.5 = 10 marks]
Choose the most appropriate answer.
1. The first language for scientific application was .
[ ] ALGOL 60 [ ] FORTRAN [ ] LISP [ ] Prolog

2. BASIC was very popular on in the late 1970s and 1980s.


[ ] Micro Computer [ ] Mini Computer
[ ] Super Computer [ ] Mainframe Computer

3. BNF is a natural notation for describing .


[ ] Sentence [ ] Statement [ ] Semantics [ ] Syntax

4. A grammar that generates a sentential form for which there are distinct parse
trees is said to be ambiguous.
[ ] Two [ ] Three [ ] Four [ ] All given options

5. A state diagram is a graph.


[ ] Hyper [ ] Directed
[ ] Unidirectional [ ] Indirect

6. An explicit and implicit declaration creates bindings.


[ ] Static [ ] Dynamic
[ ] Heap Dynamic [ ] Explicit heap dynamic & implicit heap dynamic

7. Which is a not language evaluation criterion?


[ ] Readability [ ] Writability [ ] Reliability [ ] Recoverability

8. Perl and COMMON LISP variables can be declared to have .


[ ] static scoping [ ] dynamic scoping
[ ] static and dynamic [ ] none of the above

9. An integer types that is not supported directly by the hardware is the


integer type of Python.
[ ] byte [ ] short [ ] int [ ] long

10. In Java, which is not primitive ordinal type?


[ ] integer [ ] float [ ]char [ ] boolean
11. The execution of a machine code program on a Von Neumann architecture computer
occurs in a process called the .
[ ] machine cycle [ ] fetch-execute cycle
[ ] instruction cycle [ ] execution cycle

12. The database of the prolog program consist of two kinds of statements, which are
[ ] list and atoms [ ] list and facts
[ ] facts and rules [ ] atoms and rules

13. Which is not semantic model?


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

14. The UNIX operating system is written almost entirely in .


[ ] CPL [ ] BCPL [ ]B [ ]C

15. Which of the following is the advantage of declarative languages over imperative
languages?
[ ] Can use abstract data type [ ] Easy to verify the properties of the program
[ ] Is more efficient [ ] Can be strong-typed

16. One programming language can support multiple programming paradigms.


[ ] True [ ] False

17. What kind of variable has longest lifetime?


[ ] An implicitly heap-dynamic variables [ ] A static variable
[ ] A stack-dynamic variable [ ] A fixed-length variable

18. What is the output of:


#include<stdio.h>
int main()
{
int x=40;
{
int x=20;
printf("%d",x);
}
printf("%d",x);
return 0;
}
[ ] 40 40 [ ] 20 40 [ ] 40 20 [ ] Compilation Error

19. Which of the following language is a declarative language?


[ ] Algol [ ] Prolog [ ] Java [ ] C++

20. Which one of the following is not a type of polymorphism?


[ ] coercion [ ] generics [ ] overloading [ ] overriding
KATHMANDU UNIVERSITY
End Semester Examination[C]
2014
Level : B.E.\B.Sc. Course : COMP 301
Year : III Semester : I
Time : 2 hrs 30 mins F.M. : 40
____________________________________________________________________________
SECTION “B”
[6 Q.  4= 24 marks]

Attempt any SIX questions:

1. In what language is UNIX written? What is aliasing? Explain different aspects of the cost of
a programming language.

2. Define syntax and semantics. Write a grammar for the language consisting of string that have
n copies of the letter a followed by the same number of copies of the letter b, where n>0. For
example, the string ab, aaaabbbb, and aaaaaaaabbbbbbbb are in the language but a, abb, ba,
and aaabb are not.

3. Define lexeme and token with examples. Explain two grammars characteristic that prohibit
them from being used as the basic for a top-down parser.

4. In what way are reserved words better than keywords? What are the advantage and
disadvantage of dynamic scoping?

5. What is a descriptor? What languages support negative subscripts? Define row major order
and column major order.

6. Define operator precedence and operator associativity? What is mixed-mode expression?


Define functional side effect.

7. What are the three general characteristic of subprogram? What are formal parameters and
actual parameters? Explain with examples.
SECTION “C”
[2 Q.  8 = 16 marks]

8. Show a complete parse, including the parse stack contents, input string, and action for the
string id+id*id, using the grammar and parse table given below.
Grammar:
1. E E+T
2. E T
3. T T*F
4. T F
5. F  (E)
6. F id

9. What three extensions are common to most EBNFs?


a. Given the following BNF
expr(list)|a
list list, expr | expr
Draw the parse tree for ((a,a),a,(a))
b. Convert the given regular expressions into FSA.
Regular expression: (0v1)*010(0v1)*
Regular expression: (11*)*(110v01)

10. What are the design issues for subprograms? What are the modes, the concept models of
transfer, the advantages, and the disadvantages of pass-by-value, pass-by-result, pass-by-
value-result, and pass-by-reference parameter-passing methods?

You might also like