Intro To Programming - Lecture Notes 1
Intro To Programming - Lecture Notes 1
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.
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
SDBIT 301 : Introduction to Structured Programming
since the code directly manipulates the hardware of the computer. Machine language is in
hexadecimal format (0-9,A-F)
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
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.
Reading Assignment – read on the Program Development Process and steps involved
These determine the design to be adopted and the programming language to use. For us, this is fixed
to C.
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.
3
SDBIT 301 : Introduction to Structured Programming
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.
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:
4
SDBIT 301 : Introduction to Structured Programming