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.

1
What is the correct order of steps in an algorithm to add two numbers?
Medium 1 Mark
You need the numbers before you can add them.
A Start > Display Sum > Input A > Input B > Compute Sum > End
B Start > Input A > Input B > Compute Sum > Display Sum > End
C Start > Compute Sum > Input A > Input B > Display Sum > End
D Start > Display Sum > Compute Sum > Input A > Input B > End
2
What is a flowchart?
Easy 1 Mark
Flow + chart = a diagram showing how things flow.
A A type of programming language
B A graphical representation of an algorithm
C A list of programming errors
D A hardware diagram
3
Which flowchart symbol represents the Start and End of a program?
Easy 1 Mark
Think of it as the terminal points of a journey.
A Rectangle
B Diamond
C Parallelogram
D Oval (Terminator)
4
Which flowchart symbol is used for calculations or processing instructions?
Easy 1 Mark
Rectangular boxes = doing work/processing.
A Oval
B Diamond
C Rectangle (Process)
D Parallelogram
5
Which flowchart symbol is used for input and output operations?
Easy 1 Mark
It is slanted like data entering or leaving the process.
A Diamond
B Rectangle
C Oval
D Parallelogram
6
Which flowchart symbol is used for decision making?
Easy 1 Mark
Decisions have two paths like a diamond splitting directions.
A Rectangle
B Oval
C Diamond
D Parallelogram
7
What do flow lines (arrows) represent in a flowchart?
Easy 1 Mark
Arrows show where to go next.
A Input and output data
B The direction of program execution
C Decision points
D Start and end points
8
Which of the following is NOT an advantage of flowcharts?
Medium 1 Mark
Flowcharts are planning tools not coding tools.
A Easy to understand program logic
B Helps detect logical errors
C Replaces the need for programming languages
D Improves program documentation
9
What language do computers directly understand?
Easy 1 Mark
Computers speak in 0s and 1s.
A Python
B Assembly Language
C Machine Language
D C++
10
Which of the following is a Low-Level Language?
Easy 1 Mark
Low-level = close to hardware.
A Python
B Java
C Assembly Language
D JavaScript
11
Which of the following is a High-Level Language?
Easy 1 Mark
High-level = human-friendly.
A Machine Language
B Assembly Language
C Binary Code
D Python
12
What is the main characteristic of Machine Language?
Medium 1 Mark
Machines speak binary.
A It uses English-like words
B It consists entirely of binary digits (0 and 1)
C It requires an assembler for translation
D It is machine independent
13
Which of the following is a characteristic of High-Level Languages?
Medium 1 Mark
High-level languages are portable across machines.
A Machine dependent
B Difficult to read and write
C Machine independent
D Directly executed without translation
14
Which tool is required to translate Assembly Language into Machine Language?
Medium 1 Mark
Assembler translates Assembly Language.
A Compiler
B Interpreter
C Assembler
D Linker
15
Which of the following is NOT a High-Level Language?
Easy 1 Mark
Assembly is close to hardware and not human-friendly.
A C++
B Java
C Assembly Language
D PHP
16
What is a key disadvantage of Machine Language?
Medium 1 Mark
Reading 0s and 1s is not easy for humans.
A Slow execution
B Machine independent
C Difficult for humans to read and write
D Requires a compiler
17
What is the purpose of a language translator?
Easy 1 Mark
Translators convert one language to another.
A To design flowcharts
B To convert programs into machine code for execution
C To manage computer memory
D To create operating systems
18
Which translator converts the entire source code into machine code at once?
Medium 1 Mark
Compiler = complete translation at once.
A Interpreter
B Assembler
C Compiler
D Linker
19
Which translator executes a program line by line?
Medium 1 Mark
Interpreter = line by line.
A Compiler
B Assembler
C Linker
D Interpreter
20
Which of the following languages uses a compiler for translation?
Medium 1 Mark
C++ is compiled into fast executable programs.
A Python
B Ruby
C C++
D JavaScript
Question Palette
0/34 Answered
Showing 1 - 20 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 11
Medium 9
Hard 0