Notes Computer
Chapter 1: Algorithm and Flowchart
10.2 Algorithm
Definition: An algorithm is a finite set of instructions or rules
designed to solve a problem or perform a specific task.
Characteristics:
1. Input: The data provided to the algorithm.
2. Output: The expected result.
3. Definiteness: Each step must be clear and unambiguous.
4. Finiteness: The algorithm must terminate after a finite number of
steps.
5. Effectiveness: The steps must be simple and feasible.
10.3 Basic Operations in a Program
Input: Data provided by the user.
Process: Operations like arithmetic, comparison, etc., are performed
on the data.
Output: The final result after processing.
10.4 Examples of Algorithm
1. Algorithm to find the sum of two numbers:
1. Start
2. Input number1, number2
3. Sum = number1 + number2
4. Print Sum
5. End
2. Algorithm to check if a number is even or odd:
1. Start
2. Input number
3. If number mod 2 == 0, then print "Even"
4. Else print "Odd"
5. End
10.5 Problems with Algorithms
Complexity: Some problems may require overly complex algorithms.
Inefficiency: Not all algorithms are optimized for time or space.
Ambiguity: Vague steps can lead to different outcomes.
10.6 Flowchart
Definition: A flowchart is a diagrammatic representation of an
algorithm using symbols to show steps and flow of control.
10.6.1 Flowchart Symbols
Oval: Start/End
Parallelogram: Input/Output
Rectangle: Process
Diamond: Decision
Arrow: Flow of control
10.6.2 Rules for Making a Flowchart
1. Every flowchart starts with Start and ends with Stop.
2. Arrows show the flow between steps.
3. Decisions are represented by diamonds and are answered with
Yes/No or True/False.
10.6.3 Advantages of Using Flowcharts
Visual representation makes it easier to understand complex
processes.
Simplifies debugging and documentation.
10.6.4 Disadvantages of Using Flowcharts
Large and complex flowcharts are hard to manage.
Time-consuming to draw and update for bigger problems.
10.6.5 Types of Flow
Sequential Flow: Linear, step-by-step process.
Decision-based Flow: Branching based on decisions, such as Yes/No
paths.
10.7 Some Examples of Flowchart
1. Flowchart for Finding the Sum of Two Numbers:
Start → Input num1, num2 → Process: sum = num1 + num2 →
Output sum → End
2. Flowchart for Checking Even or Odd:
Start → Input number → Decision: number mod 2 == 0? → Yes: Even
→ No: Odd → End
10.8 Divide and Conquer Strategy
Definition: A method where a problem is divided into smaller sub-
problems, solved individually, and their results are combined.
Example: Merge Sort Algorithm.
---
Chapter 2: BASIC Programming
11.1 Introduction to BASIC
BASIC: Beginner's All-purpose Symbolic Instruction Code, a simple
programming language developed to ease the process of coding for
beginners.
11.2 History of BASIC
Developed in the 1960s to make programming accessible to non-
specialists.
11.3 Character Set
Comprises letters (A-Z), digits (0-9), and special characters (+, -, *, /,
etc.).
11.4 Constants
Definition: Values that do not change during the program's
execution.
Example: LET PI = 3.14
11.5 Variable
Definition: A value that can change during the execution of a
program.
Example: LET X = 5 (X is a variable that stores the value 5)
11.6 Enhancement of BASIC
Modern versions of BASIC include more features like structured
programming and improved debugging tools.
11.7 Operators and Arithmetic Expressions
Operators: Symbols used to perform operations. Examples include +
(addition), - (subtraction), * (multiplication), and / (division).
Example: LET A = 10 + 5 (A stores the result 15).
11.8 Structure of a BASIC Program
1. Input: Accepts user data.
2. Process: Operations performed on data.
3. Output: Display results.
11.9 Simple BASIC Statements
1. REM Statement: Adds comments to the code.
Example: REM This is a comment
2. LET Statement: Assigns values to variables.
Example: LET A = 10
3. INPUT Statement: Takes user input.
Example: INPUT "Enter value"; X
4. READ and DATA Statement: Reads data from a list.
5. RESTORE Statement: Restores data for reuse.
6. PRINT Statement: Outputs data.
Example: PRINT "The result is "; A
7. STOP Statement: Stops the program.
8. END Statement: Marks the end of the program.
11.10 Printer Control
Commands to control the printer output formatting, such as LPRINT.
11.11 Program Control – Jumping, Branching, and Looping
1. GOTO Statement: Moves the program flow to a specified line.
Example: GOTO 100
2. IF…THEN Statement: Makes decisions.
Example: IF A > 10 THEN PRINT "A is greater than 10"
3. FOR…TO…NEXT Statement: Creates a loop.
Example:
FOR I = 1 TO 5
PRINT I
NEXT I
11.12 Some Examples of BASIC Program
1. Example Program to Add Two Numbers:
INPUT "Enter first number", A
INPUT "Enter second number", B
LET C = A + B
PRINT "The sum is"; C
END
2. Example Program to Check Even or Odd:
INPUT "Enter a number"; A
IF A MOD 2 = 0 THEN
PRINT "Even"
ELSE
PRINT "Odd"
END IF
END