Unit 2: Introduction to Programming Languages

🧭 Introduction

In Unit 1, you learned what a computer is and how it works internally.\ In Unit 2, we move one step forward and learn how humans communicate with computers through programming languages.

This unit is extremely important because:

  • Every software, app, or system program is written using a programming language
  • It explains how programs are created, translated, and executed
  • It builds a foundation for C programming (covered in the next unit)
  • Many exam questions directly come from this unit

If you clearly understand Unit 2, learning C and other languages becomes much easier.


🔑 Key Concepts (Explained in Simple Language)

1️⃣ What is a Programming Language?

A programming language is a set of rules, symbols, and keywords used to write instructions that a computer can understand and execute.

  • A program = a set of instructions
  • A language = the tool used to write those instructions

Examples:

  • C, C++, Java, Python
  • SQL (used for databases)
  • HTML (used for web pages)

2️⃣ Evolution of Programming Languages

Programming languages did not appear all at once. They evolved step‑by‑step to make programming easier.

🔹 Low‑Level Languages

  • Close to hardware
  • Includes Machine Language and Assembly Language
  • Very fast but difficult to write and understand
  • Machine dependent

Example:

01010101 11001100

🔹 High‑Level Languages

  • Closer to human language
  • Easy to read, write, and debug
  • Machine independent

Examples:

  • C, C++, Java, Python, FORTRAN, COBOL

3️⃣ Types of Programming Languages

✅ Procedural Languages

  • Program divided into steps (procedures/functions)
  • Focus on how to do a task

Examples: C, FORTRAN, COBOL

✅ Object‑Oriented Languages

  • Program organized using objects and classes
  • Supports reuse and real‑world modeling

Examples: C++, Java, Python

✅ Functional Languages

  • Focus on functions and expressions
  • Uses recursion

Examples: Lisp, Haskell, Scala

✅ Declarative Languages

  • Focus on what result is needed, not how
  • No step‑by‑step instructions

Examples: SQL, Prolog, HTML


4️⃣ Structured Programming

Structured programming improves clarity and reliability of programs by avoiding confusing jumps like goto.

It is based on three basic concepts:

  1. Sequence – statements execute one after another
  2. Selection – decision making (if, switch)
  3. Iteration – repetition (for, while)

Benefits:

  • Easy to read
  • Easy to debug
  • Easy to maintain
  • Encourages modular design

5️⃣ Language Processors

Computers do not understand high‑level languages directly.\ So we use language processors.

🔹 Compiler

  • Translates entire program at once
  • Produces executable file
  • Faster execution

Examples: GCC (C compiler)

🔹 Interpreter

  • Translates line by line
  • No executable file
  • Slower but easier for debugging

Examples: Python, JavaScript


6️⃣ Compilation Process (Step‑by‑Step)

  1. Preprocessor – handles #include, #define
  2. Compiler – checks syntax & translates to assembly
  3. Assembler – converts to object code
  4. Linker – links libraries → executable
  5. Loader – loads program into memory for execution

7️⃣ Compiler Phases

A compiler works in multiple phases:

  1. Lexical Analysis – breaks code into tokens
  2. Syntax Analysis – checks grammar rules
  3. Semantic Analysis – checks meaning & data types
  4. Code Generation – produces machine code

8️⃣ Object Code, Source Code & Executable Code

TypeMeaning
Source CodeProgram written by user
Object CodeMachine code, not executable
Executable CodeFinal runnable program

9️⃣ Algorithms

An algorithm is a step‑by‑step solution to a problem.

Key characteristics:

  • Input
  • Output
  • Correctness
  • Efficiency

Ways to represent algorithms:

  • Natural language
  • Pseudocode
  • Flowchart
  • Programming language

🔟 Flowcharts

A flowchart is a diagrammatic representation of an algorithm.

Common symbols:

  • Oval – Start / End
  • Rectangle – Process
  • Diamond – Decision
  • Parallelogram – Input/Output

Flowcharts help in:

  • Understanding logic
  • Debugging programs
  • Explaining answers in exams

📝 Important Exam Questions (From Past Papers)

  1. How does the compilation process help programs to be understood by computers?
  2. Differentiate compiler and interpreter.
  3. Why is a language processor needed?
  4. Explain phases of compilation.
  5. What is structured programming and its benefits?
  6. Define algorithm. Explain steps involved in algorithm design.
  7. What is a flowchart? Draw a flowchart to check even or odd number.

🧩 Step‑by‑Step Explanation Example

👉 Flowchart: Check Even or Odd

Logic:

  1. Start
  2. Read number
  3. Check number % 2 == 0
  4. If true → Even
  5. Else → Odd
  6. Stop

🎯 Exam Tips / Key Points to Remember

  • Always draw diagrams (flowchart, compilation stages)
  • Use comparison tables for compiler vs interpreter
  • Write definitions first, then the explanation
  • Mention examples (languages, tools) in answers
  • Algorithms & flowcharts are scoring topics

✅ Short Summary

Unit 2 explains how programs are written, translated, and executed.\ You learned about:

  • Programming languages and their evolution
  • Types of languages
  • Structured programming
  • Compilers, interpreters, and translators
  • Compilation process and its phases
  • Algorithms and flowcharts


Netra Koirala

Netra Koirala

Computer Science Educator

Passionate computer science educator and author. Provides free study notes, practical guides, and tutorials for Class 9, 10, 11, 12, and B.Sc CSIT students in Nepal. Years of teaching experience in computer science fundamentals.

Computer Science notes, tutorials, MCQs, and educational resources for Nepal students. Covering Class 9, SEE preparation, Class 11, Class 12, SLC, programming, DBMS, networking, HTML, JavaScript, PHP, OOP and more.

Featured Post

Grade 10 Computer Science: Specification Grid & Model Questions

Specification Grid & Model Questions of Computer Science | Grade 10 📚 Examination Resource Specification Grid & M...

Followers