Programming Fundamentals

30 minutes Intermediate 34 Questions
Topic Overview

9. Programming Fundamentals Algorithms, Flowcharts, Programming Languages (Low-level vs High-level), Translators (Compiler, Interpreter, Assembler),

Complete Topic Overview

9. Programming Fundamentals


Introduction to Programming Fundamentals


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.


Algorithms


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.

Characteristics of a Good Algorithm

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.

Example of a Simple Algorithm

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.


Flowcharts


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.

Common Flowchart Symbols

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.

Advantages of Flowcharts

Flowcharts provide several benefits:

  • Easy to understand program logic
  • Helps detect logical errors
  • Improves program documentation
  • Makes communication between programmers easier
  • Simplifies debugging and maintenance

Flowcharts are widely used in system design and program planning.


Programming Languages (Low-Level vs High-Level)


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

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

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:

  • Fast execution
  • Direct communication with hardware
  • Difficult for humans to read and write
  • Machine dependent

Assembly Language

Assembly language uses symbolic instructions instead of binary numbers.

Example:

ADD A, B
MOV AX, BX

Characteristics:

  • Easier than machine language
  • Still closely related to hardware
  • Requires an assembler for translation
  • Machine dependent

High-Level Languages

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:

  • C
  • C++
  • Java
  • Python
  • PHP
  • JavaScript

Characteristics:

  • Easy to understand and write
  • Machine independent
  • Faster development
  • Requires translation into machine language before execution

High-level languages allow programmers to focus on solving problems instead of dealing with hardware details.


Translators (Compiler, Interpreter, Assembler)


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.


Compiler

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

  • Translates the whole program at once
  • Produces object or executable code
  • Errors are displayed after compilation
  • Faster program execution after compilation

Example languages that use compilers:

  • C
  • C++
  • Go
  • Rust

Interpreter

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

  • Translates code line by line
  • Easier debugging
  • Slower execution compared to compiled programs
  • No separate executable file is generated

Example languages that use interpreters:

  • Python
  • JavaScript
  • Ruby

Assembler

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.


Conclusion


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.

21
Which of the following languages uses an interpreter?
Medium 1 Mark
Python runs line by line without a separate compile step.
A C
B C++
C Go
D Python
22
What is a key advantage of an interpreter over a compiler?
Medium 1 Mark
Errors are found immediately line by line with an interpreter.
A Faster execution
B Produces executable files
C Easier debugging
D Translates the whole program at once
23
What is a key advantage of a compiler over an interpreter?
Medium 1 Mark
After compiling no translation is needed at runtime.
A Easier debugging
B Faster program execution after compilation
C No executable file is generated
D Translates code line by line
24
Which translator is specifically used for Assembly Language?
Easy 1 Mark
Assembler = Assembly Language translator.
A Compiler
B Interpreter
C Assembler
D Debugger
25
When does a compiler display errors in a program?
Medium 1 Mark
A compiler reads everything first then reports errors.
A Before compilation starts
B Line by line during execution
C After compiling the entire program
D Only when the program runs successfully
26
Which of the following statements about an interpreter is TRUE?
Hard 1 Mark
No executable file is created by an interpreter.
A It translates the whole program at once
B It generates a separate executable file
C It produces faster execution than a compiler
D It does not generate a separate executable file
27
What is the main purpose of programming fundamentals?
Easy 1 Mark
Think about what a programmer does before writing code.
A To design computer hardware
B To create logical solutions and convert them into computer instructions
C To manage operating system resources
D To install software applications
28
What must a programmer do before writing a program?
Easy 1 Mark
Planning comes before coding.
A Install the operating system
B Choose a text editor
C Understand the problem and design a clear solution
D Select the output device
29
What is an algorithm?
Easy 1 Mark
Think of a recipe — step-by-step instructions.
A A graphical representation of a program
B A step-by-step procedure used to solve a problem
C A type of programming language
D A hardware component
30
Which characteristic of an algorithm means it must end after a finite number of steps?
Medium 1 Mark
Finite = limited/ending.
A Definiteness
B Effectiveness
C Finiteness
D Input
31
Which characteristic of a good algorithm requires each step to be clearly defined and unambiguous?
Medium 1 Mark
Definite = clear and specific.
A Finiteness
B Definiteness
C Effectiveness
D Output
32
What is the minimum number of outputs a good algorithm must produce?
Easy 1 Mark
An algorithm without a result is pointless.
A Zero
B Two
C At least one
D As many as inputs
33
How many inputs may an algorithm take?
Easy 1 Mark
Input is not always required.
A Exactly one
B Zero or more
C At least two
D Exactly two
34
In which language are algorithms written?
Easy 1 Mark
Algorithms are meant for humans to read first.
A Machine language (binary)
B Assembly language
C Simple easily understood language
D Only Python
Question Palette
0/34 Answered
Showing 21 - 34 of 34
Instructions:
  • Click on an option to select your answer
  • Use the hint button if you need help
  • Track your progress with the question palette
  • Submit your answers to see results
Difficulty Distribution
Easy 7
Medium 6
Hard 1