Introduction to Programming - Complete Notes
1. Introduction to Programming
Programming is the process of writing instructions that a computer can execute to perform specific tasks.
It involves writing code in a programming language such as C, C++, Java, or Python.
2. Computer System and Its Components
A computer system consists of hardware and software that work together to process data.
Major components:
- Input Devices (Keyboard, Mouse) - Accept user input.
- Processing Unit (CPU) - Executes instructions.
- Memory (RAM, ROM) - Stores temporary and permanent data.
- Output Devices (Monitor, Printer) - Displays results.
- Storage Devices (HDD, SSD) - Stores data permanently.
3. Computing Environments
Computing environments refer to the different ways computers can be used:
- Standalone Systems: Single-user desktops/laptops.
- Client-Server: Network-based system where clients request services from a server.
- Distributed Computing: Multiple computers work together.
- Cloud Computing: Services like Google Drive, AWS provide resources over the internet.
4. Computer Languages
Programming languages are categorized into:
- Machine Language (Binary code: 0s & 1s)
- Assembly Language (Low-level, uses mnemonics like ADD, MOV)
- High-Level Language (C, Python, Java - easy to understand)
Introduction to Programming - Complete Notes
5. Creating and Running Programs
Steps:
1. Write code in a text editor (VS Code, CodeBlocks).
2. Save the file with a .c extension.
3. Compile using a compiler (GCC).
4. Execute the compiled program.
6. Compilation Process
Steps in the Compilation Process:
1. **Preprocessing**: Handles macros and header files.
2. **Compilation**: Converts C code to assembly.
3. **Assembly**: Converts assembly to machine code.
4. **Linking**: Links required libraries.
5. **Execution**: Runs the final executable file.
7. Algorithms, Flowcharts, and Pseudocode
- **Algorithm**: Step-by-step procedure to solve a problem.
- **Flowchart**: Graphical representation of an algorithm using symbols.
- **Pseudocode**: Writing code-like structured steps in human-readable format.
8. Introduction to C Language
- Developed by Dennis Ritchie in 1972.
- A procedural programming language used for system programming.
- **Basic Structure**: Includes header files, main function, and statements.
- **Compilation Process**: Code is compiled and linked before execution.
Introduction to Programming - Complete Notes
9. C Tokens and Elements
- **Tokens**: Basic building blocks in C (Keywords, Identifiers, Constants, Operators, Symbols).
- **Keywords**: Reserved words (int, float, if, else, return).
- **Identifiers**: User-defined names (variable names).
- **Constants**: Fixed values (10, 'A', 3.14).
- **Variables**: Named storage locations in memory.
10. Data Types and I/O Statements
- **Primary Data Types**: int, float, char, double.
- **Derived Data Types**: Arrays, Pointers, Structures.
- **Input Functions**: scanf(), gets().
- **Output Functions**: printf(), puts().
11. Operators and Expressions
- **Arithmetic Operators**: +, -, *, /, %.
- **Relational Operators**: ==, !=, >, <, >=, <=.
- **Logical Operators**: &&, ||, !.
- **Assignment Operators**: =, +=, -=.
- **Increment/Decrement Operators**: ++, --.
- **Bitwise Operators**: &, |, ^, <<, >>.
- **Operator Precedence**: Determines order of execution.
12. Type Conversion in Expressions
- **Implicit Type Conversion**: Automatic conversion (int to float).
- **Explicit Type Conversion (Type Casting)**: Using (int) or (float) to convert types manually.