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:
- Sequence – statements execute one after another
- Selection – decision making (
if,switch) - 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)
- Preprocessor – handles
#include,#define - Compiler – checks syntax & translates to assembly
- Assembler – converts to object code
- Linker – links libraries → executable
- Loader – loads program into memory for execution
7️⃣ Compiler Phases
A compiler works in multiple phases:
- Lexical Analysis – breaks code into tokens
- Syntax Analysis – checks grammar rules
- Semantic Analysis – checks meaning & data types
- Code Generation – produces machine code
8️⃣ Object Code, Source Code & Executable Code
| Type | Meaning |
|---|---|
| Source Code | Program written by user |
| Object Code | Machine code, not executable |
| Executable Code | Final 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)
- How does the compilation process help programs to be understood by computers?
- Differentiate compiler and interpreter.
- Why is a language processor needed?
- Explain phases of compilation.
- What is structured programming and its benefits?
- Define algorithm. Explain steps involved in algorithm design.
- What is a flowchart? Draw a flowchart to check even or odd number.
🧩 Step‑by‑Step Explanation Example
👉 Flowchart: Check Even or Odd
Logic:
- Start
- Read number
- Check
number % 2 == 0 - If true → Even
- Else → Odd
- 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
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.
LinkedIn ProfileRelated Posts
Loading related posts…
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...