0% found this document useful (0 votes)
38 views

Assignment 0 Compiler Design

The document contains an assignment for a Compiler Design course with multiple-choice questions (MCQs) covering fundamental concepts of compilers, interpreters, and automata. Each question includes the correct answer and a brief explanation. Topics addressed include the tasks of compilers and interpreters, types of languages, and the capabilities of finite automata.

Uploaded by

sh7936402
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Assignment 0 Compiler Design

The document contains an assignment for a Compiler Design course with multiple-choice questions (MCQs) covering fundamental concepts of compilers, interpreters, and automata. Each question includes the correct answer and a brief explanation. Topics addressed include the tasks of compilers and interpreters, types of languages, and the capabilities of finite automata.

Uploaded by

sh7936402
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

NPTEL Online Certification Courses Indian

Institute of Technology Kharagpur

Compiler Design
Assignment - Week 0
TYPE OF QUESTION:MCQ
Number ofquestions:11 Total mark: 11 X 1 = 11

Q1.
Task of a compiler is to

a) Translate one statement at a time and execute it


b) Translate the whole program to machine language
c) Translate one statement of the program at a time
d) None of the other options
ANS : b)

Explanation: A compiler is a program that translates the entire source code of a program
written in a high-level programming language into machine code or an intermediate language
in one go. The resulting code can then be executed by the machine.

Q2.
In a computer system, number of compilers for a particular programming language may
Be

a) Two
b) Three
c) Four
d) Many

ANS: d)

Explanation:
There can be many compilers for a particular programming language in a computer system.
This is because:
Platform-specific compilers: Different compilers are designed for different hardware
architectures or operating systems. For example, compilers like GCC, Clang, and Microsoft
C++ Compiler all support the C++ language but are optimized for different platforms.
Optimization and feature differences: Some compilers offer specific optimizations or
additional features that others do not. Developers may choose a compiler based on their
project's needs.
Open-source vs. proprietary: Both open-source compilers (like GCC or LLVM) and
proprietary compilers (like Intel C++ Compiler or Oracle's Java Compiler) exist for many
languages.

Specialized use cases: Some compilers are tailored for education, embedded systems, or
research purposes.
Thus, for a single programming language, there can be many compilers available.

Q3.
Natural language constructs are

a) Ambiguous
b) Unambiguous
c) May be Unambiguous or ambiguous
d) None of the other options

ANS: c)
Explanation:

Q4.
Suppose there is a compiler for C language that can generate code for Computer A. Which of
the following statements is true

a) It can be used for Computer A only


b) It can be used for any computer
c) It can be used only for computers with similar processor and operating system
d) It can be used only for computers with similar processor, operating system and
peripherals

ANS: c)

Explanation: A compiler generates machine code that is specific to a processor


architecture (e.g., x86, ARM) and, in many cases, tailored to a specific operating system (e.g.,
Windows, Linux). This is because:
Processor-specific code: Machine code instructions are designed for specific CPU
architectures. Code compiled for one processor (e.g., x86) will not run on another (e.g., ARM).
Operating system dependencies: Compilers often generate code that relies on system calls,
libraries, and APIs provided by the operating system. Code designed for one OS may not work
on another.
Peripherals: While peripherals (e.g., printers, external devices) may vary, they are typically
abstracted through drivers and APIs, so their exact configuration is not directly relevant to
the compiler.
Q5.
Which of the following data structures may be good if there are frequent search for data
items followed by insertion and deletion?

a) Array
b) Link List
c) Tree
d) Hash Table

ANS: d)

Explanation: A Hash Table is efficient for frequent searches, insertions, and deletions
because it provides O(1) average time complexity for all these operations. Data is quickly
accessed, inserted, or deleted using a key and a hash function, making it highly efficient for
dynamic data handling.

Q6.
Task of an interpreter is to

a) Translate one statement of the program at a time


b) Translate one statement at a time and execute it
c) Translate the whole program to machine language
d) None of the other options

ANS: b)

Explanation: An interpreter processes and executes a program one statement at a time. It


directly translates the high-level code into machine-executable instructions without
producing a separate machine code file.

Q7.
If an Infinite language is passed to Machine M, the subsidiary which gives a finite
solution to the infinite input tape is ______________

a) Compiler
b) Interpreter
c) Loader and linkers
d) None of the mentioned
ANS : a)

Explanation: A Compiler is used to give a finite solution to an infinite phenomenon. Example


of an infinite phenomenon is Language C, etc.

Q8.
Languages of a automata is

a) If it is accepted by automata
b) If it halts
c) If automata touch final state in its life time
d) All language are language of automata

ANS: a)

Explanation: If a string accepted by automata it is called language of automata.

Q9.
Finite automata requires minimum _______ number of stacks.

a) 1
b) 0
c) 2
d) None of the mentioned

ANS: b)
Explanation: Finite automata doesn’t require any stack operation .

Q10.
The basic limitation of finite automata is that

a) It can’t remember arbitrary large amount of information.


b) It sometimes recognize grammar that are not regular.
c) It sometimes fails to recognize regular grammar.
d) All of the mentioned

ANS: a)

Explanation: Because there is no memory associated with automata.


Q11.
Which of the following languages can be recognized by finite automata?

a) Regular languages
b) Context-free languages
c) Context-sensitive languages
d) None of the mentioned

ANS: a)

Explanation: Finite automata are limited to recognizing regular languages, which are defined
by regular expressions. They cannot handle languages requiring memory, such as context-
free or context-sensitive languages.

END of Assignment

You might also like