Professional Documents
Culture Documents
Introduction to Programming
CSC126
Fundamentals of Algorithms and
Computer Problem Solving
INTRODUCTION TO COMPUTER PROGRAM
The following terms are commonly used when describing a
computer program.
Program
• A program is a set of instructions that directs the computer to
accomplish specific tasks.
• Another term commonly used for computer programs is
software, which describes all programs that are used in a
particular computer installation together with the associated
documentation.
Programming language
• Every program is written in some programming languages that
contain the set of instructions, data and rules that are used to
construct a program.
• Examples of programming languages are C++, COBOL, and
Visual Basic.
1. Reliability of output
• A good program must be able to produce correct output. A
THE different set of input data is used to ensure the reliability of
the output.
IMPORTANCE
/ CRITERIA OF 2. Program’s efficiency
3. Interactivity
• The interaction process between the user and the program
must be well defined. The interactivity is important so that
the user knows the processing status.
• Program that are user friendly allow the users to respond to
instruction correctly and this will help the users to key in
valid input thus minimizing the errors resulted from invalid
data.
4. Program Readability
• Readability is concerned with how other person views one’s
program.
• For programmers, the use of indentation and comments are
common to improve the programs readability.
i. Indentation
• Indentation helps in making the structure of the program clearer
THE and easier to read.
• Machine languages
1100
11001010 1000001 1000101 001011
RELATIONSHIP BETWEEN COMPILERS,
INTERPRETERS AND PROGRAMS
Assembly Language
• To overcome this problem, other programming languages such as assembly
language are developed.
• Example of an assembly language:
i. Source code
• The original program written in assembly or high level
languages.
• The file containing the source code is called the source file, and
in C++ it uses the filename extension .cpp (C plus plus)
Compiling a C++ program
PSEUDOCODE
PROGRAM • Guides to create pseudocode:
DEVELOPMENT • Each step in an algorithm has not more than 2
actions.
LIFE CYCLE • Steps are done sequentially in an algorithm.
(PDLC) • Use “Start”, “End” to indicate the starting and
ending point.
• Create variable names.
• Use arithmetic symbols for mathematical
operations(+, -, /, *).
• A = B is used to represent the process of assigning
B value to A.
• Use relationship operators(<, <=, >, >=, !=, ==) to
represent the relationship between 2 values.
II. ALGORITHM DESIGN
• Example of pseudocode for the car starting
process:
• Start
• Insert the key.
PROGRAM
• Transmission is in Park (or neutral).
DEVELOPMENT
• Depress the gas pedal.
LIFE CYCLE
• Turn the key to the start position.
(PDLC) • If the engine starts within 6 second,
a) release the key to the ignition position.
• else
a) repeat step 5 and 6, not more than 5 times.
b) If more than 5 times, call the garage.
• End.
II. ALGORITHM DESIGN
FLOWCHART
• A graphical representation of geometrical
PROGRAM symbols used to show the sequence of an
DEVELOPMENT algorithm
LIFE CYCLE
(PDLC)
PROGRAM
DEVELOPMENT
LIFE CYCLE
EXAMPLE OF
FLOWCHART
III. ALGORITHM IMPLEMENTATION
The algorithm is translated into a computer
program by using a specific programming
language.
PROGRAM
The process is called coding which involves
DEVELOPMENT editing, compiling and debugging.
LIFE CYCLE
(PDLC) IV. PROGRAM TESTING
Requires testing the completed program to verify
that it produces expected output.
QUESTION:
i. Analysis
Objective: sum of two integer numbers
Data requirements:
Problem input è num1, num2 // number1,
number2
Problem Output è sum // The total of 2
integer numbers
Pseudocode:
1. Start.
2. Get two integer numbers, num1, num2.
3. Sum ß num1 + num2.
4. Display the sum.
5. End.
PROGRAM DEVELOPMENT LIFE CYCLE
(Example)
Flowchart:
PROGRAM DEVELOPMENT LIFE CYCLE
(Example)
iii. Implementation:
PROGRAM DEVELOPMENT LIFE CYCLE
(Example)
iii. Implementation:
PROGRAM DEVELOPMENT LIFE CYCLE
(Example)
iv. Testing
Output:
Enter the first number: 1
Enter the second number: 2
The total of 2 integer numbers: 3
v. Maintenance