Lesson 1-3
Lesson 1-3
Algorithms
– referred to any computation performed via a
set of rules applied to numbers written in
decimal form.
– Step by step procedure to solve a given
problem
– Word “Algorithm” was derives from the
phonetic pronunciation of the last name of
Abu Jafar Mohammed inb musa al-
Khowarizmi
– It is a finite sequence of well-defined General Rules for Flowcharting
instructions, each of which can be
1. All boxes of the flowchart are connected
mechanically carried out in a finite amount of
with Arrows (not lines)
time
2. Flowchart symbols have an entry point on
the top of the symbol with no other entry
points. The exit point for all flowchart
symbol is on the bottom except for the
Decision symbol.
3. The Decision symbol has two exit points;
these can be on the sides or the bottom and
one side
4. Generally, a flowchart will flow from top to
Steps in making a good algorithm bottom. However, an upward flow can be
shown as long as it does not exceed 3
1. Inputs and outputs should be defined symbols
precisely 5. Connectors are used to connect breaks in the
2. Each steps in algorithm should be clear and flowchart.
unambiguous 6. Subroutines and interrupt programs have
3. Algorithm should be most effective among their own and independent flowcharts
many different ways to solve a problem 7. All flow charts start with a terminal or
4. An algorithm shouldn’t have computer code. predefined process (for interrupt programs
Instead, the algorithm should be written in or subroutines symbol.
such a way that it can be used in similar 8. All flowcharts end with a terminal.
programming languages.
What is a flowchart?
Pseudocode
- A flowchart is a diagram that depicts the
- Is an artificial and informal language that “FLOW” of the program.
helps develop algorithms
- It is useful in developing algorithms what
will be later converted into c language
programming
- It is similar to English statements and not
executed on computers
Flowcharts
- A tool developed in the computer industry,
for showing the steps involved in a process.
- A flowchart is a diagram made up of boxed,
diamonds and other shapes, connected by
arrows – each chape represents a step in the
process, and the arrows show the order in
which they occur.
Basic Flowcharting symbol
Terminal Modules
- Represented by rounded rectangles indicate a - The position of the module symbol indicates
starting or ending point the point the module is executed
- A separate flowchart can be constructed for
the module
Connectors
- Jumps to other portions of the flowchart
Decision Structure
- The flowchart segment below structures how
a decision structure is expressed in C as an
if/else statement
INTRODUCTION TO C
C Language History
- The C programming language is a structure-
oriental programming language, developed
at Bell Laboratories in 1972 by Dennis
Ritchie
- C programming language features were
derived from an earlier language called “B”
(Basic Combined Programming Language –
BCPL)
- C language was invented for implementing
Repetition Structure UNIX operating system
- The flowchart segment below shows a - In 1978, Dennis Ritchie and Brian
repetition structure expressed in C as a while Kernighan published the first edition “ The
loop C Programming Language” and commonly
known as K&R C
- The ANSI standard, or “ANSI C”, was
completed late 1988
Preprocessor Directives
#include preprocessor – It is used to include
header flies to a C program
#define – It is used to define a fragment of code that
is given with a name
Basic List of Header Files
stdio.h – input and output functions
conio.h – console input and output functions
ctype.h – character handling functions
math.h – mathematics functions
string.h – string functions
time.h – date and time functions
Key Points to Remember in C Programming
Basics
• C Programming is a case sensitive
programming languge