UNIT 1 Introduction to Structured Programming
UNIT 1 Introduction to Structured Programming
PROGRAMMING
BY: MUHUMUZA O N A N (B.SC.CS)
TEL: 0771580368
0757184445
EMAIL: onanmuhumuza14@gmail.com
2020akcs1103f@kab.ac.ug
INTRODUCTION TO STRUCTURED PROGRAMMING
• Programming means to convert problem solutions into instructions for the computer.
It also refersto the process of developing and implementing various sets of instructions to
enable a computer to do a certain task.
for load and STA for store means the code is easier to read and write. To convert an assembly code program into object code to
run on a computer requires an Assembler and each line of assembly can be replaced by the equivalent one line of object
(machine) code:
CONT…
• Such languages are sometimes still used for kernels and device drivers, i.e. the core of the operatingsystem and
for specific machine parts. More often, such languages are used in areas of intense processing, like graphics
programming, when the code needs to be optimized for performance.
• Almost every CPU architecture has a companion assembly language. Most commonly used are the assembly
languages today like Autocoder for IBM mainframe systems, Linoreum, MACRO -11,etc.
THIRD-GENERATION LANGUAGES (3GL) –
HIGH-LEVEL LANGUAGES
Third generation languages are the primary languages used in general purpose programming today. They each vary quite
widely in terms of their particular abstractions and syntax. However, they all share great enhancements in logical structure
over assembly languages.
Examples:
• Most Modern General Purpose Languages such as C, C++, C#, Java, Basic, COBOL, Lisp and ML.
FOURTH GENERATION
LANGUAGES
Fourth-generation programming languages are high-level languages built around database systems.They are generally
used in commercial environments.
Improves on 3GL and their development methods with higher abstraction and statementpower, to reduce errors and
increase development speed by reducing programming effort. They result in a reduction in the cost of software
development.
A 4GL is designed with a specific purpose in mind. For example languages to querydatabases (SQL), languages to
make reports (Oracle Reports) etc.
4GL are more oriented towards problem solving and systems engineering.
• Examples: Progress 4GL, PL/SQL, Oracle Reports, Revolution language, SAS, SPSS, SQ
FIFTH GENERATION LANGUAGES
Improves on the previous generations by skipping algorithm writing and instead provide constraints/conditions.
• While 4GL are designed to build specific programs, 5GL are designed to make the computer solve a given
problem without the programmer. The programmer only needs to worry about what problems needed to
be solved and only inputs a set of logical constraints, with no specified algorithm, and the Artificial
Intelligence (AI)-based compiler builds the program based onthese constraints
2. Low-level languages are converted to machine code without using a compiler or interpreter,
and the resulting code runs directly on the processor.
3 . A program written in a low-level language runs very quickly, and with a very small
memory footprint; an equivalent program in a high-level language will be more
heavyweight.
4. Low-level languages are simple, but are considered difficult to use, due to the numerous
technical details which must be remembered.
Cont…
High-level languages are closer to human languages and further from machine languages.
• The main advantage of high-level languages over low-level languages is that they are
easier to read, write, and maintain. Ultimately, programs written in a high-level
language must be translated into machine language by a compiler or interpreter.
• The first high-level programming languages were designed in the 1950s. Now there
are dozens of different languages, including Ada, Algol, BASIC, COBOL, C, C++,
FORTRAN, LISP, Pascal, and Prolog.
PROGRAMMING PARADIGMS
a) Unstructured Programming
• In unstructured programs, the statements are executed in sequence (one after the other) as written.
This type of programming uses the GoTo statement which allows control to be passed to any other
section in the program. When a GoTo statement is executed, the sequence continues from the
targetof the GoTo. Thus, to understand how a program works, you have to execute it. This often
makes itdifficult to understand the logic of such a program.
•
b)Structured Programming
• The approach was developed as a solution to the challenges posed by unstructured/procedural
programming. Structured programming frequently employs a top-down design model, in which
developers break the overall program structure into separate subsections.
CONT…
• A defined function or set of similar functions is coded in a separate module or sub-module, which means that
code can beloaded into memory more efficiently and that modules can be reused in other programs. After
a module has been tested individually, it is then integrated with other modules into the overall program
structure.
• Program flow follows a simple hierarchical model that employs looping constructs such as "for,""repeat," and
"while." Use ofthe "GoTo" statement is discouraged.
• Most programs will require thousands or millions of lines of code. (Windows 2000 – over 35 millions lines of
code). The importance of splitting a problem into a series of self-contained modules then becomes obvious. A
module should not exceed 100 lines, and preferably short enoughto fit on a single page or screen.
• Examples of structured programming languages include:
➢ C
➢ Pascal
➢ Fortran
➢ Cobol
➢ ALGOL, Ada and dBASE etc.
CONT…
d) Visual Programming
• A visual programming language uses a visual representation (such as graphics, drawings, animation or
icons, partially or completely). A visual language manipulates visual information or supports visual
interaction, or allows programming with visual expressions
CONT…
• A VPL allows programming with visual expressions, spatial arrangements of text and graphic
symbols, used either as elements of syntax or secondary notation. For example, many VPLs
(knownas dataflow or diagrammatic programming) are based on the idea of "boxes and
arrows", where boxes or other screen objects are treated as entities, connected by arrows, lines
or arcs which represent relations. An example of visual programming languages is Microsoft
Visual Basic which was derived from BASIC and enables the rapid application development
(RAD) of graphical user interface (GUI) applications.
CONT…
• Before you can start programming in C, you will need text editor such as a plain text
Notepad Editor though it does not offer code completion or debugging.
1.Code Editor: Allows programmers to write and edit source code efficiently.
1. Syntax highlighting
2. Auto-completion
3. Error detection
2.Compiler/Interpreter: Translates code into machine-readable format.
3.Debugger: Helps identify and fix errors in the code.
4.Build Automation Tools: Streamlines the process of compiling and linking
programs.
5.Version Control Integration: Supports versioning tools like Git for source
code management.
6.Project Management Tools: Organizes and manages project files.
ADVANTAGES C LANGUAGE