0% found this document useful (0 votes)
3 views11 pages

4_Computer%20Program

The document provides an overview of algorithms, including their properties, quality, characteristics, and types such as flowcharts and pseudo code. It outlines the steps to plan a computer program, from understanding the problem to maintenance, and discusses control structures like sequence, selection, and repetition. Additionally, it highlights the advantages and limitations of using flowcharts and pseudo code in programming logic.

Uploaded by

monika
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
3 views11 pages

4_Computer%20Program

The document provides an overview of algorithms, including their properties, quality, characteristics, and types such as flowcharts and pseudo code. It outlines the steps to plan a computer program, from understanding the problem to maintenance, and discusses control structures like sequence, selection, and repetition. Additionally, it highlights the advantages and limitations of using flowcharts and pseudo code in programming logic.

Uploaded by

monika
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 11

www.talentsprint.

com

COMPUTER PROGRAM

1. Introduction to Algorithm
Algorithm means the logic of a program. It is a step-by-step description of how to
arrive at a solution of a given problem.
(Or)
An algorithm is a description of a procedure which terminates with a result. Simple
algorithms can be implemented within a function.

Properties of an algorithm
 No ambiguity
 There should not be any uncertainty about which instruction to execute next.
The algorithm should conclude after a finite number of steps.
 The algorithm should be general.

Example:
 Biggest among two numbers
 Addition of N numbers
 Finding Factorial of a number
 Finding Fibonacci series

Steps to Solve the Problem in a Computer System


 Problem must be analyzed thoroughly
 Solution method is broken down into a sequence of small tasks
 Based on this analysis, an algorithm must be prepared to solve the problem
 The algorithm is expressed in a precise notation. This notation is known as
“Computer Program”
 The Computer program is fed to the computer
 The instruction in the program executes one after another and outputs the
expected result

TalentSprint©2015
www.talentsprint.com

Quality of Algorithm
The primary factors that are often used to judge the quality of an algorithm are
time requirement, memory requirement, and accuracy of solution.

Characteristics of an Algorithm
 In algorithms each and every instruction should be precise
 In algorithms each and every instruction should be unambiguous
 The instructions in an algorithm should not be repeated infinitely
 Ensure that the algorithm will ultimately terminate
 The algorithm should be written in sequence
 It looks like normal English
 The desired result should be obtained only after the algorithm terminates

Types of Algorithm
1. Normal English Program
2. Flowchart
3. Pseudo code
4. Decision table

1. Normal English Program: Step-by-step codes in short-form are written using


simple English language.
2. Flowchart: A flowchart is a schematic representation of an algorithm or a
stepwise process, showing the steps as boxes of various kinds, and their order
by connecting these with arrows. Flowcharts are used in designing or
documenting a process or program.
A flowchart, or flow diagram, is a graphical representation of a process or
system that details the sequencing of steps required to create output. A
flowchart is a picture of the separate steps of a process in sequential order.
(Or)

TalentSprint©2015
www.talentsprint.com

A Flowchart is a pictorial representation of an algorithm. It is often used by


programmer as a program planning tool for organizing a sequence of step
necessary to solve a problem by a computer.
The benefits of flowcharts are as follows:
 Communication - Flowcharts are better way of communicating the logic
of a system to all concerned.
 Effective analysis - With the help of flowchart, problem can be analyzed
in more effective way.
 Proper documentation - Program flowcharts serve as a good program
documentation, which is needed for various purposes.
 Efficient Coding - The flowcharts act as a guide or blueprint during the
systems analysis and program development phase.
 Proper Debugging - The flowchart helps in debugging process.
 Efficient Program Maintenance - The maintenance of operating
program becomes easy with the help of flowchart. It helps the
programmer to put efforts more efficiently on that part.

Advantages
 Logic Flowcharts are easy to understand. They provide a graphical
representation of actions to be taken.
 Logic Flowcharts are well suited for representing logic where there is
intermingling among many actions.

Disadvantages
 Logic Flowcharts may encourage the use of GoTo statements leading to
software design that is unstructured with logic that is difficult to decipher.
 Without an automated tool, it is time-consuming to maintain Logic
Flowcharts.
 Logic Flowcharts may be used during detailed logic design to specify a
module.

TalentSprint©2015
www.talentsprint.com

 However, the presence of decision boxes may encourage the use of GoTo
statements, resulting in software that is not structured. For this reason, Logic
Flowcharts may be better used during Structural Design.

Limitations of Using Flowcharts


 Complex logic - Sometimes, the program logic is quite complicated. In that
case, flowchart becomes complex and clumsy.
 Alterations and Modifications - If alterations are required the flowchart
may require re-drawing completely.
 Reproduction - As the flowchart symbols cannot be typed, reproduction of
flowchart becomes a problem.

Guidelines for Drawing a Flowchart


 In drawing a proper flowchart, all necessary requirements should be listed
out in logical order.
 The flowchart should be clear, neat and easy to follow. There should not be
any room for ambiguity in understanding the flowchart.
 The usual direction of the flow of a procedure or system is from left to right
or top to bottom.
 Only one flow line should come out from a process symbol.

 Only one flow line should enter a decision symbol, but two or three flow
lines, one for each possible answer, should leave the decision symbol.

TalentSprint©2015
www.talentsprint.com

 Only one flow line is used in conjunction with terminal symbol.

 Write within standard symbols briefly. As necessary, you can use the
annotation symbol to describe data or computational steps more clearly.
 If the flowchart becomes complex, it is better to use connector symbols to
reduce the number of flow lines. Avoid the intersection of flow lines if you
want to make it more effective and better way of communication.
 Ensure that the flowchart has a logical start and finish.
 It is useful to test the validity of the flowchart by passing through it with a
simple test data.
 The standard symbols should only be used.
 The arrowheads in the flowchart represent the direction of flow of control in
the problem.
 The usual direction of the flow of procedure is from top to bottom or left to
right. The flow lines should not cross each other.

TalentSprint©2015
www.talentsprint.com

 Be consistent in using names and variables in the flowchart.


 Keep the flowchart as simple as possible.
 Words in the flowchart symbols should be common statements and easy to
understand. Chart main line of logic, and then incorporate all the details of
logic.
 If a new page is needed for flowcharting, then use connectors for better
representation.
 Don’t chart every details or the flowchart will only be graphical represented.
Example: Find the maximum among three numbers.

TalentSprint©2015
www.talentsprint.com

3. Pseudo Code: “Pseudo” means imitation of false and “code” refers to the
instruction written in the programming language. Pseudo code is programming
analysis tool that is used for planning program logic.

Rules for Writing Pseudo Code


Write on statement per line. Capitalize initial keywords. Indent to show
hierarchy. End multi line structure. Keep statements language independent.

Guidelines:
 Statements should be in simple English
 Must produce a solution for the specified problem
 It should be concise
 Each instruction should be written in separate line and express one action.
Capitalize keywords such as READ, PRINT and so on.
 Instruction should be written from top to bottom, with one entry and one
exit. Should allow easy transition from design to coding in programming
language.

Benefits:
 Language Independent
 Easy to develop a program from pseudo code than flowchart. Easy to
translate into programming language
 It is compact
Limitations:
 No visual representation of program logic
 No accepted standards for writing pseudo codes
 Cannot be compiled or executed
 No real form or syntax rules
Examples:
 Finding a number is prime or not

TalentSprint©2015
www.talentsprint.com

4. Decision Table: A decision table is a table containing the selection of conditions


to be tested and how those conditions should be nested to arrive at the proper
action.

2. Steps to Plan the Computer Program


Step – 1: Understand the problem
 Read the problem statement
 Question users
 Inputs required
 Outputs required
 Special formulas
 Talk to users

Step – 2: Plan the logic


(a) Visual Design Tools
 Input record chart
 Printer spacing chart
 Hierarchy chart
 Flowchart
(b) Verbal Design Tools
 Narrative Description
 Pseudo code

Step – 3: Code the program


 Select an appropriate programming language
 Convert flowchart and/or Pseudo code instructions into programming
language statements

Step – 4: Test the program


 Syntax errors
 Runtime errors
 Logic errors

TalentSprint©2015
www.talentsprint.com

 Test Data Set

Step – 5: Implement the program


 Buy hardware
 Publish software
 Train users

Step – 6: Maintain the program


 Maintenance programmers
 Legacy systems
 Up to 85% of IT department budget

3. Program Control Structure and Program Paradigms


 A structured programming is a more specific approach to solve a
programming problem by using only the three basic logic structures.
 Program structures that affect the order in which statements are executed or
that affect statements are executed are called control structures.
Sequence control structure: Sequence logic is used for performing instructions
one after another in a sequence. Instructions has to follow one another in a logical
progression is sequence control structure.
Example: Addition of two numbers

TalentSprint©2015
www.talentsprint.com

Selection Control Structure: Selection logic is used for selecting the process path
out of two or more alternative paths in the program logic. It uses three control
structures called if…then, if… then…else and switch…case. Selection control
structure allows the program to make a chance between alternate paths, when it is
true or false.
Selection Control Structure: Selection logic is used for selecting the process path
out of two or more alternative paths in the program logic. It uses three control
structures called if…then, if… then…else and switch…case. Selection control
structure allows the program to make a chance between alternate paths, when it is
true or false.
Example: Largest of two numbers

Repetition Control Structure: Directs the system to loop back to a previous


statement in the program, repeating the same sequence over and again, usually
with a new data. When a sequence of statements is repeated against a condition, it
is said to a loop. Iteration logic is used for producing loops in program logic when
one or more instructions may be executed several times depending on some
condition. It uses two control structures called do…while, and repeat…until.

TalentSprint©2015
www.talentsprint.com

Example: Search a number in array

TalentSprint©2015

You might also like