Introduction To Programming: Code All at A Time
Introduction To Programming: Code All at A Time
Introduction to Programming
COMPUTER PROGRAMMING
• involves writing instructions and giving them to the computer to complete a task.
• involves tasks such as; analysis, generating algorithms, profiling algorithms' accuracy and
resource consumption, and the implementation of algorithms in a chosen programming
language
COMPUTER PROGRAM
• a set of instructions written in a computer language, in order to be executed to perform a
specific task.
• Computer Programs are also named as SOFTWARE.
PROGRAMMER
• a person who writes the required computer programs.
• translate the expected tasks given in human understandable form into machine understandable
form by using compilers and interpreters.
COMPILER- a specific software that gets the whole Source Code and translates it into Object
Code all at a time.
INTERPRETER- translating and executing one statement of Source Code into Object Code at a
time.
SOURCE CODE- Computer program written in human understandable form
OBJECT CODE- Computer Program that is in machine understandable form
STATEMENT- command of Computer Program
CHARACTERISTICS OF A PROGRAM
Well designed programs must be:
• Correct and accurate
• Easy to understand
• Easy to maintain and update
• Efficient
• Reliable
• flexible
PROGRAMMING PROCESS
1. Problem definition
• What must the program do?
• What outputs are required and in what form?
• What inputs are available and in what form?
2. Program Design involves creating an algorithm – sequence of steps, by which a computer can
produce the required outputs from the available inputs
Ch E 524
Introduction to Programming
Top-down design
• The main problem is split into subtasks
• Then each subtask is divided into simpler subtasks, etc. unless it is clear how to solve all
such subtasks
3. Program Coding means expressing the algorithm developed for solving a problem, in a
programming language
Program Compilation – translation of a program written in a high-level programming
language into machine language instructions
Compilation step converts a source program into an intermediate form, called object
code
Linking step is necessary to combine this object code with other code to produce an
executable program
The advantage of this two-step approach:
• Source of the large program may be split into more than one file
• These files are worked on and compiled separately
• Object code may be stored in libraries and used for many programs
• Then they will be combined into one executable code
TYPES OF ERRORS
• Syntax Errors: a character or string incorrectly placed in a command or instruction that
causes a failure in execution. Violation of syntactic rules in a Programming Language generates
syntax errors.
• Semantic Errors: it requires you to work backward by looking at the output of the program
and trying to figure out what it is doing. Doing logical mistakes causes semantic errors in Source
code.
• Run-time Errors: Occur on program execution. Mostly caused by invalid data entry or tries to
use not existing resources.
PROGRAMMING
Programming task can be separated into 2 phases
1. problem solving phase
• produce an ordered sequence of steps that describe solution of problem
• this sequence of steps is called an algorithm
STEPS IN PROBLEM SOLVING
• First produce a general algorithm (one can use pseudocode)
Pseudocode is an artificial and informal language that helps programmers develop algorithms.
Pseudocode is very similar to everyday English. It is a simpler version of a programming code in
plain English which uses short phrases to write code for a program before it is implemented in a
specific programming language.
Ch E 524
Introduction to Programming
• Refine the algorithm successively to get step by step detailed algorithm that is very
close to a computer language.
Algorithm is a systematic logical approach which is a well-defined, step-by-step procedure that
allows a computer to solve a problem
2. implementation phase
• implement the program in some programming language (Pascal, Basic, C, C++,
Java….etc)
THE FLOWCHART
• (Dictionary) A schematic representation of a sequence of operations, as in a manufacturing
process or computer program.
• (Technical) A graphical representation of the sequence of operations in an information system
or program. Information system flowcharts show how data flows from source documents
through the computer to final distribution to users. Program flowcharts show the sequence of
instructions in a single program or subroutine. Different symbols are used to draw each type of
flowchart.
• shows logic of an algorithm
• emphasizes individual steps and their interconnections
• e.g. control flow from one action to the next
Logical system
a) Consistency
b) Validity
c) Completeness
d) Soundness
FLOWCHART SYMBOLS
Name Symbol Use in Flowchart
Selection
Repetition
The repetition ( also known as loop )
control structure, allows one or more actions to
be repeated.