Class 8 ICT Chapter 2 Notes - OAV - Easy & Clear Explanation
Class 8 ICT Chapter 2 Notes - OAV - Easy & Clear Explanation
INTRO
A computer program is a set of instructions that takes input and gives the desired output.
Writing these instructions using a computer language is called programming.
Every language has its own rules, called **syntax**.
The people who write these programs are called **programmers**.
- **Machine Language:**
- **Assembly Language:**
** High-Level Languages **
**Compiler**
**Interpreter**
**Notable Facts**
**Constants in Programming**
- **Character Constant**: A single alphabet, digit, or symbol enclosed in single quotes (e.g., ‘b’, ‘8’, ‘%’).
- **String Constant**: A collection of characters enclosed in double quotes (e.g., “human”, “1789”).
- **Variables:** Named memory spaces whose values can change during execution. Example: `int x = 25;`
- **Data Type:** Defines the type of values a variable can store and the operations it can perform.
**Types of Data**
- **Character Type:** Stores single characters (e.g., `'A'`). Takes **1 byte** in memory. Example: `char X;`
- **Integer Type:** Stores whole numbers (e.g., `100, -25`). Takes **2 bytes** in memory. Example: `int Y;`
- **Float Type:** Stores decimal numbers (e.g., `3.14, -5.23`). Takes **4 bytes** in memory. Example: `float Z;`
**Operators in Programming**
**Definition:**
Arithmetic operators are used to perform mathematical calculations such as addition, subtraction, multiplication, division, and
more.
**Examples:**
- **Addition (`+`)** → Adds two values (e.g., `5 + 3 = 8`).
- **Subtraction (`-`)** → Subtracts one value from another (e.g., `10 - 4 = 6`).
- **Multiplication (`*`)** → Multiplies two values (e.g., `6 * 2 = 12`).
- **Division (`/`)** → Divides one value by another (e.g., `9 / 3 = 3`).
- **Exponentiation (`^`)** → Raises a number to a power (e.g., `2^3 = 8`).
- **Modulus (`MOD`)** → Returns the remainder after division (e.g., `10 MOD 3 = 1`).
Keywords Used in Algorithms:
Algorithm Structure:
Algorithm Examples:
- Start (BEGIN).
- Stop (END).
- Start (BEGIN).
- Stop (END).
FLOWCHART
A flowchart is a pictorial representation of step-by-step solution of a problem. Alternatively, it refers to the pictorial representation of an
algorithm.
Components of a Flowchart:
1. **Terminal Box**:
- Oval-shaped box.
- Parallelogram-shaped box.
- Rectangular-shaped box.
Here are the contents from the images converted into text format:
4. **Decision Box**
- **Shape**: Rhombus.
- **Function**: Represents branching based on conditions. Selects one of two paths depending on a given condition.
5. **Flow Lines**
7. **N**: No condition.
**FLOWCHART Overview**
- **Components**:
2. **STEP 2**: READ principal (p), time (t), and rate of interest (r).
3. **STEP 3**: Compute simple interest (si) using the formula: $$si = \frac{p \cdot t \cdot r}{100}$$
**Flowchart Components**
1. **Terminal Box**:
- **Shape**: Oval.
2. **Input/Output Box**:
- **Shape**: Parallelogram.
- **Purpose**: Used to take inputs (like p, t, r) and display outputs (like si).
3. **Processing Box**:
- **Shape**: Rectangle.
- **Purpose**: Represents calculations or logic, e.g., $$si = \frac{p \cdot t \cdot r}{100}$$.
4. **Decision Box**
- **Shape**: Rhombus.
- **Purpose**: Used for decision-making, selecting one path out of two based on a condition.
5.**Flow Lines**
- **Rules**:
**Problem Statement**:
Write an **algorithm** and **flowchart** to determine whether a given number is even or odd.
**Algorithm**:
3. **IF (N % 2 == 0)**:
---
3. **Decision (N % 2 == 0)**:
**Number System**
When we type some letters or words, the computer translates them into numbers, as computers can understand only numbers. The data
within the computer is represented in the following types:
- Base: 10.
- Example: (676367)
- Base: 2.
- Example: (1011101)₂
- Base: 8.
- Example: (507)₈
- Contains 16 characters: 0 to 9 and A to F (where A=10, B=11, C=12, D=13, E=14, F=15).
- Base: 16.
- Example: (A34FE)₁₆
**Steps to Convert Decimal to Binary**
3. Use the quotient from each division as the input for the next division.
5. Read the remainders from bottom to top to get the binary equivalent.
- **Process**:
- 25 ÷ 2 = 12 (remainder 1)
- 12 ÷ 2 = 6 (remainder 0)
- 6 ÷ 2 = 3 (remainder 0)
- 3 ÷ 2 = 1 (remainder 1)
- 1 ÷ 2 = 0 (remainder 1)
- **Process**:
- 160 ÷ 2 = 80 (remainder 0)
- 80 ÷ 2 = 40 (remainder 0)
- 40 ÷ 2 = 20 (remainder 0)
- 20 ÷ 2 = 10 (remainder 0)
- 10 ÷ 2 = 5 (remainder 0)
- 5 ÷ 2 = 2 (remainder 1)
- 2 ÷ 2 = 1 (remainder 0)
- 1 ÷ 2 = 0 (remainder 1)
- Quotient: **101**
- Remainder: **0**
- Remainder: **0**
|---------|--------|-------|-------------|
|0 |0 |0 |0 |
|1 |1 |1 |1 |
|2 | 10 |2 |2 |
|3 | 11 |3 |3 |
|4 | 100 | 4 |4 |
|5 | 101 | 5 |5 |
|6 | 110 | 6 |6 |
|7 | 111 | 7 |7 |
|8 | 1000 | 10 | 8 |
|9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |