You are on page 1of 25

Lecture 1

Introduction to Programming

learn the basic concept in programming Identify ways how to solve problems Define what algorithm, pseudo code and flow charts are Acquire skills in handling data of different types

set of step by step instruction that directs the computer to do the task you want it to do and to produce the results wanted
The instruction provided

it is the process of designing, writing, testing , debugging and maintaining the source code of a computer programs. Or simply the process of giving instruction to computer.

Programming Language
Artificial Language designed to express computations that can be performed by a machine, particularly a computer. It can be used to create programs that control the behavior of a machine, to express the algorithm precisely.

Example of Progg Languages

C++ JAVA Visual Basic

Programming Process
Defining the problem
Determine the requirement the program must meet.
Input data/ requirements that are inputted. Process the process Output show the result

Planning the solution
Select the best method for solving the problem.
algorithm or pseudo code Flow charting

Coding the program
Prepare the set of instructions for the computer to execute. The correct usage of programming language

Testing the program
Perform debugging the testing the program . Methods :
Disk Checking proof reading Translating uses translators to convert the program in the form that the user can understand. Debugging directs, locates and corrects bugs by running the program.

Errors in programming
Two types of bugs
Syntax error errors in spelling or grammar Semantic errors logical error, incorrect solution Signs of semantically wrong statements Incorrect results are displayed Confusing or garbled output Program hangs Runtime errors are displayed and programs terminates.

Cont. of progr process

Documenting the program
Write up the full specification for other program users. Used to make programs readable by other programmers.
Comment an important part of a program documentation.

Procedure or recipe of the program. A finite set of instruction Example: algorithm about going to office
Go to work Take a coffee break Is it time to go home? If yes then go home If no then go to work Is the boss looking?

If yes then do some work If no take a coffee break.

Algorithm for Changing, adding subject

Fill out the required form Have it approved by the registration office. Present it to the registrars office for corresponding adjustment fees. Pay our additional fees at the cashiers office. Submit your form to the registration office for verification.

Representations of algorithm Pseudo code textual representations Flow chart graphical representations or simply the blue print of the program.

Example Pseudo code: Getting the sum of two numbers.
Get the first number and call it num1 Get the second number and call it num2 Add num1 and num2 and call it sum Display sum

Blueprint of the program

Flowcharting Guidelines: A flowchart always begins with a START and is completed by an END. Symbols are interconnected by headed arrows. An arrows head indicates the direction to be followed. An oblong, hexagon, parallelogram, rectangle or circle may have only one arrow branching out, but may have one or more arrows branching in.

Flowchart cont.
A diamond must have more than one arrow branching out, may have one or more arrows branching in. Circles are used to connect one part of a flowchart to another on the same page. The sequence of the symbols matters. It indicates the stepby-step logic to be followed. A flowchart may contain as many symbols of the same kind as necessary in the solution of the problem. There may be an infinite number of flowcharts to solve one problem. There is no just one correct flowchart. A flowchart is efficient if it is simple and if it contains the fewest possible number of symbols to solve the problem.

Flowchart Symbols
Input/Output Symbol (Parallelogram) represents an instruction to an input or an output device Processing Symbol (Rectangle) represent a group of program instructions that perform a processing function such as arithmetic operation, or to compare, sort, etc

Flowchart Symbols
Decision symbol (Diamond) denotes a point in the program where more than one path can be taken. Terminal Symbol (Oval) used to designate beginning and the end of the program

Flowchart Symbols
Decision symbol (Diamond) denotes a point in the program where more than one path can be taken. Terminal Symbol (Oval) used to designate beginning and the end of the program

Flowchart Symbols
Preparation Symbol declaring variables and constants Flow line indicates the sequence of steps and the direction of flow

Example Flowchart
Simple flow