BCA Sem 1 | Unit 1 | Computer Concepts & C Programming
Introduction of Logic & Basics of Algorithms — BKNMU Junagadh
Boolean Logic, Logic Gates, Truth Tables, Algorithms, Flowcharts, and Pseudo-code
Computers make decisions using hardware switches called Logic Gates. The three primary building block gates are:
1. AND Gate
Outputs True (1) ONLY if ALL inputs are True. Acts like logical multiplication (1 × 0 = 0).
2. OR Gate
Outputs True (1) if AT LEAST ONE input is True. Acts like logical addition (1 + 0 = 1).
3. NOT Gate (Inverter)
Inverts the input value. Converts True (1) to False (0) and False (0) to True (1).
Here is a summary table of fundamental logic gates, their symbols, logical equations, and output rules:
| Logic Gate | Boolean Expression | Condition Rule | Truth Table Summary |
|---|---|---|---|
AND Gate | Y = A . B | Output is 1 only when input A is 1 AND input B is 1. Otherwise, output is 0. | 0&0=0, 0&1=0, 1&0=0, 1&1=1 |
OR Gate | Y = A + B | Output is 1 when input A is 1 OR input B is 1 (or both). Output is 0 only when both are 0. | 0|0=0, 0|1=1, 1|0=1, 1|1=1 |
NOT Gate | Y = A' | Single-input gate that reverses the binary input signal. | Input 0 ➔ Output 1 Input 1 ➔ Output 0 |
The 4-Step Decision Flow of an Algorithm:
An algorithm receives input, tests logical conditions, carries out instructions based on those decisions, and terminates after producing the output.
- Uses standard geometric shapes connected by arrows.
- Oval: Start / Stop terminal.
- Parallelogram: Input / Output operation.
- Rectangle: Processing / Calculation step.
- Diamond: Decision / Condition branching.
- Written in structured, plain English-like sentences.
- Not bound by strict compiler syntax like C.
- Focuses on algorithm logic rather than language syntax.
- Uses keywords like
START,INPUT,IF-ELSE,PRINT,END.
Here is how a problem is represented as a structured algorithm and pseudo-code before writing actual C code:
1. Input & Output Defined
Must accept zero or more well-defined inputs and produce at least one output result.
2. Definiteness (Unambiguous)
Every step must be completely clear, direct, and have only one interpretation.
3. Finiteness
The algorithm must terminate after a finite number of steps. It must never run endlessly.
4. Effectiveness
Every step must be simple enough that it can be carried out basic processing manually or in finite time.
- Boolean Logic: Logic system using binary values
1(True) and0(False). - Primary Logic Gates: AND (both true), OR (any true), NOT (inverts value).
- Truth Table: Chart displaying outputs for all possible binary input combinations.
- Algorithm: A finite, step-by-step logical process for solving a problem.
- Flowchart: Visual diagram of an algorithm using standard geometric symbols.
- Pseudo-code: Informal, structured plain-English description of code logic.
- Algorithm Rules: Must be finite, unambiguous, effective, and produce output.