All Exams Test series for 1 year @ ₹349 only
Question

Arrange the given compilation process in the correct order.

a. Linking

b. Assembling

c. Compiling

d. Pre-processing

The correct answer is

d → c → b → a

The compilation process is a fundamental sequence of steps that transforms human-readable source code into an executable program that a computer can understand and run. Understanding the correct order of these stages is essential in software development and for optimizing program performance.

Compilation Process Steps Explained

Let's arrange the given stages of the compilation process in their correct sequential order, from the initial source code to the final executable program:

  1. Pre-processing (d): This is the very first stage in the compilation process. During pre-processing, a special program called the pre-processor handles directives that begin with a '#' symbol. Common pre-processor directives include #include (for including header files), #define (for defining macros), and conditional compilation directives like #ifdef. The pre-processor expands macros, includes the content of specified header files into the source code, and removes comments. The output of this stage is an expanded source code file, which is still in a high-level language but is now ready for the next stage.
  2. Compiling (c): After pre-processing, the compiler takes the expanded source code file as its input. The compiler's primary role is to translate this high-level programming language code (like C or C++) into assembly code. Assembly code is a low-level language that is specific to a particular computer's architecture (CPU). It's much closer to machine language but is still human-readable in a symbolic form. The output of this stage is an assembly file.
  3. Assembling (b): The assembler takes the assembly code generated by the compiler as its input. Its function is to translate this assembly code into machine code, which consists of binary instructions (zeros and ones) that the computer's central processing unit (CPU) can directly execute. This machine code is then stored in an object file. Object files contain machine code for specific parts of the program but are not yet executable on their own because they might have references to external functions or routines that are located in other object files or libraries.
  4. Linking (a): This is the final stage of the entire compilation process. The linker takes one or more object files (produced by the assembler) and combines them into a single, complete executable program. It resolves all external references by finding the actual memory addresses of functions and variables that are defined in other object files or in standard libraries (like input/output functions). If all references are successfully resolved, the linker produces an executable file, which is the final program that can be run directly by the operating system.

Process Order Summary Table

The entire compilation process can be clearly summarized in the following sequential table:

Order Stage Name Description Input Output
1st Pre-processing Handles directives (e.g., #include, #define) and expands macros. Source Code Expanded Source Code
2nd Compiling Translates high-level code into assembly code. Expanded Source Code Assembly Code
3rd Assembling Translates assembly code into machine code. Assembly Code Object File
4th Linking Combines object files and libraries to create an executable program. Object Files & Libraries Executable File

Final Arrangement of Compilation Stages

Based on the detailed explanation of each stage of the compilation process, the correct sequential order of the given steps is:

  • d. Pre-processing
  • c. Compiling
  • b. Assembling
  • a. Linking

Therefore, the correct arrangement is d → c → b → a.

Was this answer helpful?

Important Questions from Lexical Analysis

  1. What is the output of a lexical analyzer?

  2. Which of the following are applications of symbol table ?

    (A) Storage allocation

    (B) Checking type compatability

    (C) Suppressing duplicate error messages

    Choose the correct answer from the options given below:

  3. Which ONE of the following statements is FALSE regarding the symbol table?

  4. A lexical analyzer uses the following token definitions
    • $letter \rightarrow [A-Z a-z]$
    • $digit \rightarrow [0-9]$
    • $id \rightarrow letter(letter \mid digit)^*$
    • $number \rightarrow digit^+$
    • $ws \rightarrow (blank \mid tab \mid newline)^+$

    For the string given below,

    $x1 \quad 23mm \quad 78 \quad y \quad 7z \quad zz5 \quad 14A \quad 8H \quad AaYcD$

    the number of tokens (excluding $ws$) that will be produced by the lexical analyzer is __________. (answer in integer)
Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App