Structure Programming
ICT-1105
Information and Communication
Technology
Lecture-03
1
Creating and Running Programs
There are four steps in this process.
1. Writing and editing the program using
Text editor (source code).
2. Compile the program using any C
compiler.(.bak file)
3. Linking the program with the required
library modules(object file)
4. Executing the program. (.Exe file)
2
Creating and Running Programs
Creating and Editing a C Program in C
Programming Language compiler:
Writing or creating and editing source
program is a first step in c language.
Source
code is written in c programming language
according to the type of problem or
requirement, in any text editor.
3
Creating and Running Programs
Saving C Program in C Programming
Language:
Source code is saved on the secondary
storage. Source code is saved as text file.
The extension of file must be ".c".
Example: The file name is "learn c
programming language.c"
4
Creating and Running Programs
Compiling C program in C Programming
Language:
Computer does not understand c
programming language. It understands
only 0 and 1 means machine language. So c
programming language code is converted
into machine language. The process of
converting source code in to machine
code is called compiling.
5
Creating and Running Programs
Compiling C program in C Programming
Language:
Compiler is a program that compiles
source code. Compiler also detects errors
in source program. If compiling is
successful source program is converted
into object program. Object program is
saved on disk. The extension of file is ".obj"
6
Creating and Running Programs
Linking in C programming Language:
There are many built in functions available
in c programming language. These
functions are also called library functions.
These functions are stored in different
header files.
7
Creating and Running Programs
Loading program:
The process of transferring a program from
secondary storage to main memory for
execution is called loading a program.
A program called loader does loading.
8
Creating and Running Programs
Executing program:
Execution is the last step. In this step
program starts execution. Its instructions
start working and output of the program
display on the screen.
9
Creating and Running Programs
10
Pseudocode
An artificial and informal language that
helps programmers develop algorithms.
Pseudocode is very similar to everyday
English.
11
Algorithm
An algorithm is a description of a
procedure which terminates with a result.
Algorithm is a step-by-step method of
solving a problem.
12
Properties of an Algorithm
1.Finiteness:- An algorithm terminates after a finite
numbers of steps.
2.Definiteness:- Each step in algorithm is unambiguous. This
means that the action specified by the step cannot be
interpreted (explain the meaning of) in multiple ways & can
be performed without any confusion.
3.Input: - An algorithm accepts zero or more inputs.
4.Output:- An algorithm should produce at least one
output.
5.Effectiveness:- It consists of basic instructions that are
realizable. This means that the instructions can be
performed by using the given inputs in a finite amount of
time. 13
Writing an algorithm
An algorithm can be written in English, like
sentences and using mathematical formulas.
Sometimes algorithm written in English like
language is Pseudo code.
Examples:
Finding the average of three numbers
14
Writing an algorithm
1. Let a,b,c are three integers
2. Let d is float
3. Display the message “Enter any three
integers:”
4. Read three integers and stores in a,b,c
5. Compute the d = (a+b+c)/3.0
6. Display “The avg is:” , d
7. End.
15
Writing an algorithm
Example 1:
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.
16
Writing an algorithm
Pseudocode:
▪ Input a set of 4 marks
▪ Calculate their average by summing and
dividing by 4
▪ if average is below 40
Print “FAIL”
else
Print “PASS”
17
Writing an algorithm
Detailed Algorithm :
Step 1: Input M1,M2,M3,M4
Step 2: GRADE ← (M1+M2+M3+M4)/4
Step 3: if (GRADE < 40) then
Print “FAIL”
else
Print “PASS”
end if
18
Flowcharts
The pictorial representation of algorithm is
called flowchart.
Uses of flow chart:
1. Flow chart helps to understand the program
easily.
2. As different symbols are used to specify the
type of operation performed, it is easier to
understand the complex programs with the help
of flowcharts.
19
Flowchart Symbols
20
Flowchart Symbols
21
Writing an algorithm
Try yourself:
Algorithm to find whether a number even or
odd
22
System Development
23
System Development
24
System Development
1. Statement of Problem
❑ Working with existing system and using
proper questionnaire, the problem
should be explained clearly.
❑ What inputs are available, what outputs
are required and what is needed for
creating workable solution, should be
understood clearly
25
System Development
2. Analysis
❑ The method of solutions to solve the
problem can be identified.
❑ We also judge that which method gives
best results among different methods of
solution.
26
System Development
3. Design
❑ Algorithms and flow charts will be
prepared.
❑ Focus on data, architecture, user
interfaces and program components.
27
System Development
4. System Test
The algorithms and flow charts developed
in the previous steps are converted into
actual programs in the high level languages
like C.
28
System Development
4. System Test
a. Compilation
The process of translating the program into machine
code is called as Compilation. Syntactic errors are
found quickly at the time of compiling the program.
These errors occur due to the usage of wrong
syntaxes for the statements.
Eg: x = a * y + b
There is a syntax error in this statement, since, each
and every statement in C language ends with a
semicolon (;).
29
System Development
4. System Test
b. Execution
The next step is Program execution. In this phase, we
may encounter two types of errors.
Runtime Errors: These errors occur during the execution
of the program and terminate the program abnormally.
Logical Errors: These errors occur due to incorrect usage
of the instructions in the program. These errors are
neither detected during compilation or execution nor
cause any stoppage to the program execution but
produces incorrect output.
30
System Development
5. Maintenance
We are maintenance the software by
updating the information, providing the
security and license for the software.
31
Thank you….
32