[go: up one dir, main page]

0% found this document useful (0 votes)
1K views13 pages

Class 8 ICT Chapter 2 Notes - OAV - Easy & Clear Explanation

The document provides an overview of programming concepts, including the definition of a computer program, types of programming languages, and basic programming elements such as variables, data types, and operators. It explains the differences between machine, assembly, high-level, fourth, and fifth generation languages, along with the roles of compilers and interpreters. Additionally, it covers algorithms, flowcharts, and number systems, detailing how to convert between different numeral systems.

Uploaded by

arnparichha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views13 pages

Class 8 ICT Chapter 2 Notes - OAV - Easy & Clear Explanation

The document provides an overview of programming concepts, including the definition of a computer program, types of programming languages, and basic programming elements such as variables, data types, and operators. It explains the differences between machine, assembly, high-level, fourth, and fifth generation languages, along with the roles of compilers and interpreters. Additionally, it covers algorithms, flowcharts, and number systems, detailing how to convert between different numeral systems.

Uploaded by

arnparichha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

CHAPTER-1PROGRAMMING CONCEPT

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**.

**Generation of Computer Language**:

 Computer programs are written using computer languages.


 These languages are grouped into 5 types:
1) **Machine Language** – uses 0s and 1s.
2) **Assembly Language** – uses short codes (like MOV, ADD).
3) **High-Level Language** – easy to understand (like Python, C).
4) **4th Generation Language** – easier and faster (like SQL).
5) **5th Generation Language** – used for AI and problem-solving (like Prolog).

- **Machine Language:**

 Consists of binary code (0s and 1s).


 Directly understood by the CPU.
 Hard to write and debug due to its complexity.

- **Assembly Language:**

 Uses mnemonics (e.g., MOV, ADD) for easier readability.


 Requires an assembler to convert into machine language.
 Faster than high-level languages but harder to code than them.

** High-Level Languages **

 Similar to English, making programming easier.


 Require an interpreter or compiler to convert into machine language.
 Used for developing software, websites, and applications.

### Examples of High-Level Languages

o **BASIC:** Beginners All Purpose Symbolic Instruction Code


o **COBOL:** Common Business Oriented Language
o **FORTRAN:** Formula Translation
o **LOGO:** Logic Oriented Graphic Oriented programming language
o **C & C++:** Powerful programming languages used in system and application development

**Compiler**

 Converts **high-level language** into **machine language** all at once.


 Works **fast** because it translates the entire program before execution.
 Detects all errors **after translation**, requiring the entire program to be debugged.

**Interpreter**

 Converts **high-level language** into **machine language** **line by line**.


 Works **slowly** since it translates one instruction at a time.
 Stops at the first error and requires fixing before continuing.

### **Additional Notes**

**Source Code**: Code written by the programmer in a programming language.


**Object Code**: Intermediate code between source code and executable machine code.
**4th Generation Language**

 Highly user-friendly, fast execution.


 Requires minimal effort to get results.
 Example: **SQL (Structured Query Language)**

**5th Generation Language**

 Uses **Artificial Intelligence** to achieve goals.


 AI techniques support learning and problem-solving.

**Notable Facts**

**Lady Ada Lovelace**: First lady computer programmer.


**LISP**: First AI programming language, created by **John McCarthy**.
**Spacewar**: First interactive computer game.
**John W. Turkey (1957)**: First used the term "software."

**Basic Elements of Programming**

1) **Variables:** Store data values (e.g., `x = 5`).


2) **Data Types:** Define types of data (e.g., integer, float, string).
3) **Operators:** Perform operations (e.g., `+`, `-`, `*`, `/`).
4) **Control Statements:** Guide program flow (`if-else`, `loops`).
5) **Functions:** Reusable blocks of code (`def functionName()` in Python).
6) **Syntax:** Rules for writing a program correctly.
7) **Comments:** Notes inside the code for better understanding (`// This is a comment`).

**Constants in Programming**

- **Character Constant**: A single alphabet, digit, or symbol enclosed in single quotes (e.g., ‘b’, ‘8’, ‘%’).

- **Numeric Constant**: Positive or negative numbers (e.g., 135, -235, 5.24).

- **String Constant**: A collection of characters enclosed in double quotes (e.g., “human”, “1789”).

 These values **do not change** during program execution


 Constants remain unchanged throughout the program's execution.
 They help in storing fixed values like mathematical constants or predefined data.
 Used in many programming languages, declared using specific keywords (const, final, #define).

**Definition of Variables & Data Types**

- **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**

- **Arithmetic Operators:** Perform mathematical calculations (+, -, *, /, ^, MOD).


- **Assignment Operator:** Assigns values to variables (=).
- **Relational Operators:** Compare values (<, >, !=, <=, >=).
- **Logical Operators:** Perform logical operations (AND, OR, NOT).

### **Arithmetic Operators**

**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:

- **BEGIN**: To start the algorithm.

- **READ, INPUT, ACCEPT**: To take inputs.

- **WRITE, OUTPUT, DISPLAY**: To show outputs.

- **END, GOTO**: To stop or jump to a step.

- **STEP 1, 2… N**: Denote the sequence of steps.

- **IF… ELSE… ENDIF**: For decision-making logic.

Algorithm Structure:

1. **STEP 1**: **BEGIN** - Start of the algorithm.

2. **STEP 2, 3, etc.**: List intermediate actions.

3. **STEP N**: **END** - End of the algorithm.

Algorithm Examples:

1. **Find the Sum of Two Numbers**:

- Start (BEGIN).

- Get two numbers (READ A, B).

- Add them (SUM = A + B).

- Show the result (PRINT SUM).

- Stop (END).

2. **Check if a Number is Positive**:

- Start (BEGIN).

- Get a number (READ n).

- If it's greater than 0, say it's positive (PRINT "Positive").

- Else, say it's negative (PRINT "Negative").

- 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.

- Used to mark the beginning and ending of the flowchart.

2. **Input / Output Box**:

- Parallelogram-shaped box.

- Used to read inputs and display the outputs.


3. **Processing Box**:

- Rectangular-shaped box.

- Represents assignment statements, arithmetic and logical calculations, etc.

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**

- **Purpose**: Indicate the execution flow in a flowchart.

- **Arrow**: Every line must have an arrow.

- **Rule**: Flow lines should not cross each other.

**Keywords Used in Flowcharts**

1. **START**: Marks the beginning of the flowchart.

2. **READ / INPUT / ACCEPT**: Keywords for accepting inputs.

3. **WRITE / OUTPUT / DISPLAY**: Keywords for showing outputs.

4. **STOP**: Indicates the end of the flowchart.

5. **IF**: Represents a decision-making condition.

6. **Y**: Yes condition.

7. **N**: No condition.

**FLOWCHART Overview**

- **Definition**: A pictorial representation of a step-by-step solution to a problem, or an algorithm.

- **Components**:

1. **Terminal Box**: Oval-shaped, marks start and end.

2. **Input/Output Box**: Parallelogram-shaped, reads inputs and shows outputs.

3. **Processing Box**: Rectangular, used for calculations or assignments.

**Algorithm for Calculation of Simple Interest**

1. **STEP 1**: BEGIN

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}$$

4. **STEP 4**: PRINT simple interest (si).

5. **STEP 5**: END

**Flowchart Components**
1. **Terminal Box**:

- **Shape**: Oval.

- **Purpose**: Marks the start and end of the flowchart.

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**

- **Purpose**: Indicate the execution flow of the algorithm.

- **Rules**:

- Each flow line must have an arrow.

- Flow lines should not cross each other.

**Keywords Used in Flowcharts**

1. **START**: Marks the beginning of a flowchart.

2. **READ / INPUT / ACCEPT**: Used for input data.

3. **WRITE / OUTPUT / DISPLAY**: Used for showing output data.

4. **STOP**: Marks the end of a flowchart.

5. **IF**: Used for decision-making conditions.

6. **Y**: Indicates "Yes" condition.

7. **N**: Indicates "No" condition.

**Problem Statement**:

Write an **algorithm** and **flowchart** to determine whether a given number is even or odd.

**Algorithm**:

1. **BEGIN**: Start the algorithm.

2. **READ N**: Input the number, N.

3. **IF (N % 2 == 0)**:

- **PRINT "N is an even number"**.


4. **ELSE**:

- **PRINT "N is an odd number"**.

5. **END**: Stop the algorithm.

---

### **Flowchart Description**:

1. **START**: Oval shape (Terminal Box).

2. **Input N**: Parallelogram shape (Input/Output Box).

3. **Decision (N % 2 == 0)**:

- **YES Path**: Print "N is an even number".

- **NO Path**: Print "N is an odd number".

- Rhombus shape (Decision Box).

4. **STOP**: Oval shape (Terminal Box).

**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:

1. **Decimal Number System**

- Contains ten digits: 0 to 9.

- Base: 10.

- Example: (676367)

2. **Binary Number System**

- Contains two digits: 0 and 1.

- Base: 2.

- Example: (1011101)₂

3. **Octal Number System**

- Contains eight digits: 0 to 7.

- Base: 8.

- Example: (507)₈

4. **Hexadecimal Number System**

- 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**

1. Divide the decimal number by 2.

2. Write down the remainder after each division.

3. Use the quotient from each division as the input for the next division.

4. Repeat until the quotient becomes zero.

5. Read the remainders from bottom to top to get the binary equivalent.

**Example 1: Decimal Number 25**

- **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)

- **Binary Equivalent**: **11001**

**Example 2: Decimal Number 321**

- **Process**:

- 321 ÷ 2 = 160 (remainder 1)

- 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)

- **Binary Equivalent**: **101000001**

**Example 1**: Binary Division (101 ÷ 101)

1. Divide **11010** by **101**:

- Quotient: **101**

- Remainder: **0**

**Example 2**: Binary Division (10000111 ÷ 1001)

1. Divide **10000111** by **1001**:


- Quotient: **01111**

- Remainder: **0**

Relation between Decimal, Binary, Octal, and Hexadecimal:

This table lists numbers in four numeral systems:

| Decimal | Binary | Octal | Hexadecimal |

|---------|--------|-------|-------------|

|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 |

You might also like