Professional Documents
Culture Documents
2
C is a structured language which
allows variety of programs in small
modules. It is easy for debugging,
testing & maintaining if the language is
a structured one.
3
Program – a set of detailed, step-by-step
instructions that directs the computer to
process data into information.
Programming is combination of art and
science, because you may code a program
however you like as long as you follow the
language’s rules.
Programming language – a set of rules (syntax)
and commands that provides a way of telling
the computer what operations to perform.
Programmer – designs algorithm and converts
it into computer instructions and tests
programs as developed.
4
Six main steps
1. Defining the problem
2. Planning the solution
3. Coding the program
4. Testing the program
5. Documenting the program
6. Implementing the program
5
Design the algorithm
An algorithm is a finite series of
logical steps required to solve a
particular problem.
6
An algorithm is a step-by-step description of the solution to a
problem. It is defined as an ordered sequence of well-defined
and effective operations which, when carried out for a given set
of initial conditions, produce output, and terminate in a finite
time.
7
We use algorithms almost daily in our lives
without realizing it
For example
an instruction manual
a cooking recipe
a knitting pattern
8
Aim: To write a C program for adding two
numbers
*
A flowchart is a pictorial representation of an
algorithm or logical steps.
Each step is represented by a symbol and the
arrows indicate the flow and order of the
steps.
The shape of the symbol indicates the type of
operation that is to occur.
Flowcharts may help the more visual students
learn and understand logic.
10
11
Begin or End Input or Output
Processing Decision
14
Begin
Input
price, qty
subtotal =
price * qty;
Output
subtotal
End
15
Input
Weight
True
If weight < 10 Handling = 1.00
False
Handling = 3.00
Output Handling
16
17
18
Pseudocode is a mixture of programming
code and English like statements.
19
Translate solution algorithms into a
programming language
Enter program code into programming
development tool using correct syntax
Include comments in program
Use good structure so you don’t
create spaghetti code
20
Testing the Program
⚫ Remove syntax and logic errors
⚫ Syntax error - when code violates language rules, errors
are displayed by the programming development tool.
⚫ Logic error – when program does not generated expected
output when using the test data. Error must be found by
programmer.
21
Programmer name and date
A narrative description of the
program
Include comments within the source
code
Flowcharts and/or pseudocode
Layouts of input and output records
Testing procedures
22
Implementing & Maintaining
⚫ Programs may be part of a system
implementation or single program
implementation.
⚫ Training, user manuals, technology upgrades,
and conversions must be taken into consideration
during implementation.
⚫ Programs may be enhanced to add new features
or functionality
23
A compiler translates all of the
source code into object code,
an executable program. During
this translation process, a
program listing of any syntax
errors is produced.
24
Procedural Programming
◦ Programmer must provide step-by-step instructions, telling the
computer what to do and how to do it.
◦ Logic begins at the top and flows down.
◦ Non-procedural language, such as SQL in a relational database, the
programmer specifies what is needed, and the language
determines how by using the data dictionary.
Event Programming
◦ A program listens for and reacts to events such as mouse click on a
button.
Object-Oriented Programming (OOP)
◦ Use classes to build programs.
◦ A class definition includes properties (data) and methods
(procedures) to manipulate the properties.
◦ Classes are used to declare objects that are considered an instance
of the class.
25
BASIC (Beginners’ All-purpose Symbolic Instruction Code –
1960s)
COBOL (Common Business Oriented Language 1960s)
C - Used to develop UNIX in 1970s;
runs on most operating system now
C++ - A better C, Object oriented; (1980s)
Java - Similar to C++;
Became popular because of web development – applets,
Programs run on multiple platforms (Win, Unix, Mac),
Originally named Oak (1991) and renamed to Java in 1995
Visual Basic – Microsoft created language so that graphical
user interfaces could be created for their new operating
system – Windows (1990s)
C# (c-sharp) – Microsoft’s newest language (2002);
syntax is similar to Java, but uses the same library items as
VB.
26
Sum of 2 numbers
Calculate Simple and compound interest
Convert Celcius into Fahrenheit and Vice
Versa
Find out the area of a triangle
Find out the largest of 2 numbers
Find out whether the given number is ODD or
EVEN
Find the factorial of a number
27
➢ Simple & Compound
SI = ((p*r*n)/100);
q = 1+(r/100);
CI=p*pow(q,n)-p;
➢ area of a triangle
s = (a + b + c) / 2;
area = sqrt(s * (s - a) * (s - b) * (s - c));
28