Program Design

Program Design

Published by: Nuru

Published date: 21 Jun 2021

Program Design Photo

Program Design

Program design involves preparing the algorithms for the problem.
Algorithm: An algorithm is a clear and unambiguous specification of the steps needed to solve a problem.

An algorithm may be expressed as in either form,
1. Human language (e.g. English)
2. Pseudocode
3. Graphical Representation (Flow-Chart)

Algorithm Representation: Pseudocode

Pseudocode - is a cross between human language and a programming language.
• A pseudocode is:
– An artificial and informal language that helps programmers to develop algorithms
– Not an actual programming language
– Not actually executed on computers
• Why do we need Pseudocode?
– Helps to “think out” a program before writing it
– May be converted easily into a corresponding programming language code.
Algorithm Example
Problem: Compute the average marks of students obtained in a TEST of "Computer Programming"

• Human Language Specification: (In English)

1. Read the no of students
2. Read the marks of each student
3. Sum the marks of all students as total marks.
4. Divide the total marks by the number of students.
5. Report the result of division as average marks of students.

• Pseudocode Specification:

1. Input N
2. Input N marks: m1,m2,m3,..... mN
3. T =(m1+ m2+m3+... ... ....+ mN)/N
4. A=T/N
5. Output A

 

  • Flow Chart

Program design also includes a flowchart. A flow-chart is:
• the graphical representation of the algorithm for any problem.
• useful for developing and representing algorithms.
• is drawn using certain special-purpose symbols connected by arrows called flowlines.
• The symbols indicate the actions to be performed, and flowlines indicate the order in which actions are to be performed

Flow Chart Symbols

Program Design

Flow Chart: Example
Flow chart to solve the problem to find the average marks of students

Program Design

 

Example: Pseudocode and Flow chart

Problem: Print the grade of the student based on the input score

• Input the marks of a student
• if the mark is greater than or equal to 90 print “A”
• else
if a student’s mark is greater than or equal to 80 print “B”
• else
if a student’s mark is greater than or equal to 70
print “C”
else
• if student’s mark is greater than or equal to 60
print “D”
• else
print “F”

Flowchart

Program Design

 

Structure of C program

The general form of a C program is as follows :
• Preprocessor directives - Starting with symbol #
• Global declarations of user functions
• Global variables declarations
• main()
{
local variables to function main ;
statements associated with function main ;
}

function1()

{
local variables to function 1 ; /*comment*/
statements associated with function 1 ;
}