Programming for Problem Solving (PPS)
Unit 1 – Introduction to Programming (Detailed Notes)
1.1 Introduction to Computers
• A computer is an electronic machine that processes data into information according to
instructions (programs).
• Tasks: Input → Process → Output → Storage → Communication.
• Characteristics: High speed, accuracy, automation, storage capacity, versatility.
1.1.1 Components of a Computer System
• Input Unit: Devices like keyboard, mouse, scanner. Converts data → binary → memory.
• Output Unit: Monitor, printer, speakers. Converts binary → human-readable form.
• Memory Unit: Stores data and instructions temporarily/permanently.
• - Primary: RAM (volatile), ROM (non-volatile).
• - Secondary: HDD, SSD, CD/DVD, Pen drive.
• Arithmetic and Logic Unit (ALU): Performs arithmetic (+, −, *, /) and logical (<, >, =) operations.
• Control Unit (CU): Directs flow of instructions (Fetch → Decode → Execute → Write Back).
• Central Processing Unit (CPU) = ALU + CU + Memory.
• Peripherals = Input + Output devices.
1.1.2 Hardware
• Hardware refers to physical parts of the computer.
• Examples: Motherboard, Processor, Hard disk, Monitor, Keyboard, Mouse.
1.1.3 Software
• Software = Set of instructions/programs controlling hardware.
• Types of Software:
• 1. System Software – OS, Compilers, Interpreters, Assemblers.
• 2. Application Software – MS Word, Tally, Reservation Systems.
• 3. Utility Software – Antivirus, Compression tools, Disk management tools.
1.1.3.1 Operating System
• OS acts as resource manager (CPU, Memory, I/O).
• Provides interface between user and hardware.
• Examples:
• - PCs: Windows, Linux, Unix, Solaris, BOSS.
• - Mobiles: Android, iOS, Symbian.
1.1.3.2 Language Translators
• Assembler: Translates assembly language → machine language.
• Compiler: Translates high-level language → machine code at once. Produces object code.
Faster execution.
• Interpreter: Translates and executes line by line. Slower, but useful for debugging.
1.1.3.3 Programming Environment
• Environment to write, compile, execute programs.
• Includes: Editor, Compiler, Linker, Loader, Debugger.
• Popular IDEs: Turbo C/C++, CodeBlocks, Visual Studio, Eclipse.
1.1.4 Booting Concept
• Process of starting the computer and loading OS into memory.
• Steps: Power on → BIOS POST → Bootloader → Load OS.
• Types:
• - Cold Booting: Fresh start after power ON.
• - Warm Booting: Restart without switching OFF (Ctrl+Alt+Del).
1.2 Algorithms
• Definition: Finite step-by-step procedure to solve a problem.
• Characteristics: Input, Output, Definiteness, Finiteness, Effectiveness.
• Representation:
• - Flowchart (Graphical symbols).
• - Pseudocode (English-like structured steps).
1.2.1 Flowcharts
• Symbols: Oval (Start/Stop), Parallelogram (I/O), Rectangle (Process), Diamond (Decision).
• Shows step-by-step logic with arrows.
1.2.2 Pseudocode
• English-like instructions.
• Uses: Sequence, Selection, Iteration.
• Helps in program design before coding.
1.3 From Algorithm to Program
• Steps: Problem → Algorithm → Flowchart/Pseudocode → C Program → Compilation →
Execution.
• Structure of C Program:
• #include
• void main() {
• int a, b, sum;
• sum = a + b;
• printf('%d', sum);
• }
1.4 C Language Basics
• Features: Portable, Structured, Mid-level, Efficient, Rich library.
• Applications: OS Development, Compilers, Embedded Systems.
• Building Blocks:
• - Character set, Tokens, Identifiers.
• - Data types: int, float, char, double.
• - Variables, Constants.
• - Expressions and Statements.
• - Input/Output: scanf(), printf().
1.5 Example Problems
• Even/Odd check using mod operator.
• Largest of three numbers using nested if.
• Grade assignment (A+, A, B, C, D, F) using if-else ladder.
• Commission calculation based on sales.
• Palindrome, Armstrong, Prime number check using loops.
• Fibonacci sequence generation.
Unit Summary (Exam Pointers)
• IPO cycle, CPU components.
• Hardware vs Software, OS and Translators.
• Booting process (Cold vs Warm).
• Algorithm, Flowchart, Pseudocode.
• Structure of C Program, Tokens, Data types.
• Common example problems.