Chapter 1: Introduction to Computing
📌 Learning Objectives
- LO 1.1: Know the structure of a computer and have an idea about its functioning
- LO 1.2: Learn to develop programming logic through algorithms and flowcharts
1.1 Components of a Computer
A computer is an electronic device used to perform computations involving arithmetic and logical operations. The major components are the CPU, input devices, output devices, and memory.
+-----------+ +-----------------+ +------------+
| Input |---->| |---->| Output |
| Devices | | CPU | | Devices |
+-----------+ | | +------------+
+-----------------+
^
|
v
+-----------------+
| Memory |
+-----------------+
Fig. 1.1: Basic components of a computer
Central Processing Unit (CPU)
The CPU is the unit where all processing takes place. It consists of:
- ALU (Arithmetic Logic Unit): Performs arithmetic and logical operations
- Control Unit: Generates control signals; the "brain of the computer"
- Registers: High-speed storage within the CPU
Memory
Memory is classified into:
- Primary Memory (Main Memory): RAM (volatile) and ROM (non-volatile)
- Secondary Memory: Hard disk, flash drives (non-volatile, larger capacity)
1.2 Algorithms and Flowcharts
An algorithm is a finite set of unambiguous instructions that, when executed, performs a task correctly. It has three characteristics:
- Finite number of steps
- Unambiguous instructions
- Solves the problem correctly
Example 1: Algorithm to Find Average of Three Numbers
📝 Worked-Out Problem 1.1
Algorithm AVERAGE:
Step 0: START Step 1: INPUT first number into variable A Step 2: INPUT second number into variable B Step 3: INPUT third number into variable C Step 4: COMPUTE SUM = A + B + C Step 5: COMPUTE AVG = SUM / 3 Step 6: DISPLAY AVG Step 7: END
Flowchart Symbols
| Symbol | Name | Description |
|---|---|---|
| □ | Terminal | Start/End of flowchart |
| ▱ | Input/Output | Input or output operation |
| □ | Process | Processing/imperative statement |
| ◇ | Decision | Conditional/decision making |
Example 2: Finding Maximum of Two Numbers
📝 Worked-Out Problem 1.2
Algorithm MAXIMUM:
Step 0: START
Step 1: INPUT first number into A
Step 2: INPUT second number into B
Step 3: IF A > B THEN
MAX = A
ELSE
MAX = B
END IF
Step 4: DISPLAY MAX
Step 5: END
Flowchart:
[START]
|
v
[INPUT A, B]
|
v
/ \
/ \
/ A>B? \
/ \
/ \
(True) (False)
| |
v v
[MAX = A] [MAX = B]
| |
\ /
\ /
\ /
v v
[DISPLAY MAX]
|
v
[END]
1.3 Example 3: Sum of First N Natural Numbers (Iteration)
📝 Worked-Out Problem 1.3
Algorithm SUM-N:
Step 0: START
Step 1: INPUT N
Step 2: I = 1
Step 3: SUM = 0
Step 4: REPEAT Steps (a)-(b) WHILE I <= N
(a) SUM = SUM + I
(b) I = I + 1
END WHILE
Step 5: DISPLAY SUM
Step 6: END
Chapter Exercises
Review Questions
- Write an algorithm and draw a flowchart to find the area of a circle of a given radius.
- Write an algorithm and draw a flowchart to find the roots of a quadratic equation.
- Write an algorithm and draw a flowchart to find out whether a year is a leap year.
- Write an algorithm and draw a flowchart to count the number of digits present in a number.
- Write an algorithm and draw a flowchart to find the sum of the series: 2 + 4 + 6 + ... + N terms.
Multiple Choice Questions
- The major hardware components of a computer are:
a) CPU, Memory, I/O devices
b) Operating System, Compiler, Assembler
c) ALU, Control Unit, Registers
d) None of the above - Which of the following is a system software?
a) Word Processor
b) Compiler
c) Spreadsheet
d) Database - An algorithm must be:
a) Finite
b) Unambiguous
c) Correct
d) All of the above
Debugging Exercises
Identify the errors in the following flowchart segments (not shown here due to space). Consider common mistakes like missing decision branches or incorrect loop conditions.
Programming Exercises
- Write a program to find the average of three numbers. (Hint: This will be your first C program in Chapter 2!)
- Draw a flowchart to find the sum of digits of a 3-digit number.