9. Programming Fundamentals Algorithms, Flowcharts, Programming Languages (Low-level vs High-level), Translators (Compiler, Interpreter, Assembler),
Programming fundamentals are the basic concepts used to create computer programs. These concepts help programmers design logical solutions to problems and convert those solutions into instructions that a computer can execute.
Programming involves writing instructions using a programming language so that a computer can perform specific tasks such as calculations, data processing, automation, and problem solving.
Before writing a program, a programmer must first understand the problem and design a clear solution. This is usually done using algorithms and flowcharts, which describe the steps needed to solve the problem.
An algorithm is a step-by-step procedure used to solve a problem or perform a specific task.
It describes the logical sequence of instructions that must be followed to achieve the desired result. Algorithms are written in simple language so they can be easily understood before converting them into a programming language.
A good algorithm should have the following properties:
1. Input
An algorithm may take zero or more inputs.
2. Output
It must produce at least one output or result.
3. Definiteness
Each step of the algorithm should be clearly defined and unambiguous.
4. Finiteness
The algorithm must end after a finite number of steps.
5. Effectiveness
Each step must be simple enough to be carried out by a computer.
Algorithm to add two numbers:
Step 1: Start
Step 2: Input number A
Step 3: Input number B
Step 4: Compute Sum = A + B
Step 5: Display Sum
Step 6: End
This algorithm explains the logical process for solving the problem before writing a program.
Algorithms are important because they help programmers plan solutions and reduce errors in programming.
A flowchart is a graphical representation of an algorithm. It uses different symbols and arrows to represent the sequence of steps in solving a problem.
Flowcharts make complex logic easier to understand by visually displaying how the program will operate.
1. Terminator (Start/End)
Oval shape used to represent the start and end of a program.
2. Process Symbol
Rectangle shape used for calculations or instructions.
Example:
Sum = A + B
3. Input/Output Symbol
Parallelogram used for reading input or displaying output.
Example:
Input A Display Result
4. Decision Symbol
Diamond shape used for decision making or conditional checks.
Example:
Is number > 0 ?
5. Flow Lines
Arrows used to show the direction of program execution.
Flowcharts provide several benefits:
Flowcharts are widely used in system design and program planning.
A programming language is a formal language used to write instructions that a computer can execute.
Computers understand only machine language, which consists of binary numbers (0 and 1). Programming languages make it easier for humans to write programs that can later be translated into machine language.
Programming languages are generally divided into low-level languages and high-level languages.
Low-level languages are closer to the hardware and machine instructions of a computer.
They provide very little abstraction from the hardware.
Two main types of low-level languages are:
Machine language consists entirely of binary digits (0 and 1). It is the only language directly understood by the computer's processor.
Example:
10110000 01100001
Characteristics:
Assembly language uses symbolic instructions instead of binary numbers.
Example:
ADD A, B MOV AX, BX
Characteristics:
High-level languages are designed to be easy for humans to read and write.
They use English-like words and mathematical symbols to express program logic.
Examples of high-level languages include:
Characteristics:
High-level languages allow programmers to focus on solving problems instead of dealing with hardware details.
Since computers understand only machine language, programs written in high-level or assembly languages must be translated into machine code before execution.
Programs that perform this translation are called language translators.
A compiler is a program that translates the entire source code of a high-level program into machine code at once.
After compilation, an executable program is generated.
Characteristics of a Compiler
Example languages that use compilers:
An interpreter translates and executes a program line by line.
Instead of generating a separate executable file, the interpreter executes each instruction immediately after translation.
Characteristics of an Interpreter
Example languages that use interpreters:
An assembler is a translator used to convert assembly language into machine language.
It converts symbolic instructions into binary instructions that the processor can understand.
Example:
Assembly instruction
ADD A, B
Machine code output
10110000
Assemblers are mainly used in low-level programming where direct control over hardware is required.
Programming fundamentals form the foundation of computer programming and software development. Concepts such as algorithms and flowcharts help in designing logical solutions to problems before writing actual code. Programming languages provide a structured way to communicate instructions to computers, while translators like compilers, interpreters, and assemblers convert these instructions into machine code that computers can execute.
Understanding these fundamentals is essential for learning programming and developing efficient software systems.