0% found this document useful (0 votes)
48 views

Intro To Programming - Lecture Notes 1

The document provides an introduction to programming concepts including input/output, data types, variables, flow control, compilation vs interpretation, low-level vs high-level languages, and structured vs object-oriented programming. It also discusses program development processes, design tools like flowcharts and pseudocode, and common types of programming errors.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Intro To Programming - Lecture Notes 1

The document provides an introduction to programming concepts including input/output, data types, variables, flow control, compilation vs interpretation, low-level vs high-level languages, and structured vs object-oriented programming. It also discusses program development processes, design tools like flowcharts and pseudocode, and common types of programming errors.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

lOMoARcPSD|14513725

Intro To Programming - Lecture notes 1

Network programming (KCA University)

Studocu is not sponsored or endorsed by any college or university


Downloaded by Andre Deyniel Cabrera ([email protected])
lOMoARcPSD|14513725

1 INTRODUCTION TO PROGRAMMING
A computer program (also software, or just a program) is a sequence of instructions written to
perform a specified task with a computer. A computer requires programs to function, typically
executing the program's instructions in a central processor. The program has an executable form
that the computer can use directly to execute the instructions.

Computer source code is written by computer programmers. It is converted into a format that the
computer processor can understand in a process called compilation. The process of writing a
computer program is called programming.

Computer programs are collections of instructions that tell a computer how to interact with the
user, interact with the computer hardware and process data.

1.1 Programming Concepts


Some of the concepts involved in programming include

 Input/output
 Data types, variables, constants and memory allocation
 Flow control
 Language interpretation (compilation vs. interpretation)
 High level programming languages vs. Low level programming languages
 Top –down vs. Bottom up decomposition
 Structured vs. Object oriented programming models

In this course we shall focus on structured programming and other concepts relating to the
programming language “C”.

1.2 Programming Languages


A programming language is an artificial language designed to communicate instructions to a
machine, particularly a computer. Programming languages can be used to create programs that
control the behaviour of a machine and/or to express algorithms precisely.

A programming language is a notation for writing programs, which are specifications of a


computation or algorithm. A programming language's surface form is known as its syntax. Most
programming languages are purely textual; they use sequences of text including words, numbers,
and punctuation, much like written natural languages. On the other hand, there are some
programming languages which are more graphical in nature, using visual relationships between
symbols to specify a program.

Low Level Programming Languages


The first programmable computers required the programmers to write explicit instructions to
directly manipulate the hardware of the computer. This "machine language" was very tedious to
write by hand since even simple tasks such as printing some output on the screen require 10 or 20
machine language commands. Machine language is often referred to as a "low level language"

1
SDBIT 301 : Introduction to Structured Programming

Downloaded by Andre Deyniel Cabrera ([email protected])


lOMoARcPSD|14513725

since the code directly manipulates the hardware of the computer. Machine language is in
hexadecimal format (0-9,A-F)

High Level Programming Languages


By contrast, higher level languages such as C, C++, Pascal, Cobol, Fortran, ADA and Java are called "
high level languages ". They do not manipulate the computer hardware directly and require to be
translated into a form that can be directly understood by the computer hardware. A single
instruction in a high level language translates into several lines of machine language and can
perform complex operations. These languages also have a syntax (grammar) that closely resembles
the English language, making them more human readable.

1.3 Program Translation


High level programming languages require translation to machine code so that they can be
processed by the computer processor since their syntax doesn’t match machine code. This
translation can be in either of 2 formats.

Compilation
In a compiled language, the programmer writes more general instructions and a compiler (a special
piece of software) automatically translates these high level instructions into machine language. The
machine language is then executed by the computer. A large portion of software in use today is
programmed in this fashion. High level languages such as C, C++, Pascal, Cobol, Fortran, ADA and
Java are called "compiled languages"

Interpretation
In an interpreted programming language, the statements that the programmer writes are
interpreted as the program is running. This means they are translated into machine language as the
program is running and then execute as the program is running. Some popular interpreted languages
include Basic, Visual Basic, Perl and shell scripting languages such as those found in the UNIX
environment.

2
SDBIT 301 : Introduction to Structured Programming

Downloaded by Andre Deyniel Cabrera ([email protected])


lOMoARcPSD|14513725

2 PROGRAM DEVELOPMENT AND DESIGN


Program Development refers to the process of coming up with a computer program from scratch to
solve a given problem. It involves several steps some of which do not involve a computer at all.

Program design is the determination of the form, structure and algorithm that a computer program
shall have. It’s the arrangement of the various elements of a program to come up with the best
quality of a program to solve the problem at hand. Program design is one of the steps in the program
development process.

2.1 Introduction to Program Development Process


There are several program development models. They include the Waterfall model, Spiral model,
Iterative and incremental development, Agile development and the Code and fix models.

Reading Assignment – read on the Program Development Process and steps involved

2.2 Issues in Program Design


When designing a program, most issues relate to the model adopted and the quality of the program
that will be written in relation to the problem that was to be solved. Some of the issues involved are:

 Need for a GUI (Graphical User Interface)


 Type of variables and memory allocation
 Input /Output formats and devices
 Speed of execution of the program
 Type of translator e.t.c

These determine the design to be adopted and the programming language to use. For us, this is fixed
to C.

Reading Assignment – read on the Properties of a good programming language

Reading Assignment – read on the qualities of a good program

2.3 Program Design Tools – Algorithms


An algorithm is a representation of a solution to a problem. An algorithm is an effective method
expressed as a finite list of well-defined instructions for calculating a function.

In other words, an algorithm is a step-by-step procedure to solve a given problem. Algorithms can
be said to show the flow of logic within a computer program. We usually express or describe
algorithms using some program design tools; flowcharts, pseudo-codes and decision trees.

2.3.1 Flow Charts


A flowchart is a diagrammatic representation of the steps followed in solving a problem or
describing an algorithm. Flowcharting is a tool developed in the computer industry, for showing the
steps involved in a process. A flowchart is a diagram made up of boxes, diamonds and other shapes,
connected by arrows - each shape represents a step in the process, and the arrows show the order
in which they occur. A Flowchart shows logic of an algorithm and emphasizes individual steps and
their interconnections.

3
SDBIT 301 : Introduction to Structured Programming

Downloaded by Andre Deyniel Cabrera ([email protected])


lOMoARcPSD|14513725

See Handout 1: The Flowchart

2.3.2 Pseudo-Codes
A pseudo-code is an informal code written by a programmer in his own language to describe an
algorithm and assists him/her to develop a source code easily.

Pseudocode is one of the tools that can be used to write a preliminary plan that can be developed
into a computer program. Pseudocode is a generic way of describing an algorithm without use of
any specific programming language syntax. It is, as the name suggests, pseudo code —it cannot be
executed on a real computer, but it models and resembles real programming code, and is written at
roughly the same level of detail.

An example of a pseudo-code is given below:

Example 2.3.2: Write an algorithm to determine a student’s final grade and indicate whether it is
passing or failing. The final grade is calculated as the average of four marks.

Algorithm:

 Input a set of 4 marks


 Calculate their average by summing and dividing by 4
 if average is below 50
Print “FAIL”
else
Print “PASS”
Pseudo Code
Step 1: Input M1,M2,M3,M4
Step 2: GRADE  (M1+M2+M3+M4)/4
Step 3: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
endif

2.3.3 Decision Trees


Reading Assignment : Read on the use of decision trees in developing computer programs

2.4 Program Errors


Humans aren’t perfect. To be human is to err. Program errors arise from incorrect development or
design of a program. The errors cause ’bugs’ in a program and cause a program not to function
properly. There are 3 main types of program errors:

1. Syntax Errors – affecting the syntax of a program


2. Semantic Errors – affecting the meaning of a program code
3. Logic Errors – affecting logic flow in a program

Reading Assignment : Read more on program errors

4
SDBIT 301 : Introduction to Structured Programming

Downloaded by Andre Deyniel Cabrera ([email protected])

You might also like