0% found this document useful (0 votes)
10 views39 pages

Module 13 Program Analysis

The document is a chapter on Program Analysis from a Computer Science curriculum, detailing the steps involved in computer programming, including problem definition, analysis, and program design. It covers the concepts of algorithms and flowcharts, providing definitions, examples, and symbols used in flowcharts. Additionally, it includes practical exercises and a questionnaire to reinforce understanding of the material.

Uploaded by

imrindia216
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views39 pages

Module 13 Program Analysis

The document is a chapter on Program Analysis from a Computer Science curriculum, detailing the steps involved in computer programming, including problem definition, analysis, and program design. It covers the concepts of algorithms and flowcharts, providing definitions, examples, and symbols used in flowcharts. Additionally, it includes practical exercises and a questionnaire to reinforce understanding of the material.

Uploaded by

imrindia216
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

FYJC

COMPUTER SCIENCE I
CHAPTER
PROGRAM ANALYSIS
MRS. PALLAVI BHAMRE
THIS CHAPTER WILL IMPROVE
YOUR PROGRAMMING SKILLS
MODULE 13
CHAPTER : PROGRAM ANALYSIS

Introduction
 Steps of Development of Computer Programming
 Pseudo code
 Algorithm
 Hands on Training
 Flowchart
 Hands on Training
 QUESTIONNARIE
Computer Programming :

Computer Programming can be defined as a process,


which results in the development of a computer program.

A program : A program is a set of instructions stored in


the computer, developed by a user, used to direct the
computer for desired result.

Pseudo code:- Pseudo code is a code expressed


in English like language. It broadly explains the
solution of the problem.
Steps of Development of Computer Programming: 3 STEPS :

PROBLEM DEFINTION PHASE

PROBLEM ANALYSIS PHASE

PROGRAM DESIGN PHASE


1. Problem Definition Phase : Defining the Problem
■We must first of all understand, what is the
actual problem.
■Understand the problem through right angle :
is necessary to proceed in right direction.
■Defining a problem correctly, avoids the
confusion about the problem while writing the
program.
2. Problem Analysis Phase : Analyzing the Problem

■ After clearing what is the problem & what to do,


■ We must find how to solve that problem.
■ We collect of all possible details required for solving a problem.
■ Concentrate on the inputs required and output produced.
■ Concentrate on the way chosen for solving the problem.
■ If many ways to find the solution, choose or fix to a particular way.
3. Program Design Phase : Designing the Program

■ Start with Designing the Computer Program.


■ Design means finding a logic to solve that problem.
■ Solution is provided on paper.
■ Write down the steps, required to solve the problem.
■Design a solution is done by writing an
algorithm and/ or drawing a flowchart.
3. Program Design Phase : Algorithm :
■ Algorithm :
■ Definition : Algorithm is a way of representing the problem solving
steps in English like language.
■ Algorithm is expressed in Pseudo Code.
■ Pseudo Code : Definition : A code expressed in English – like
language used to describe steps of algorithm.
■ Designing an algorithm is the process done before writing the
program.
■ Write down the logical steps to be performed to solve the
concerned problem.
Algorithm :
■ Illustration of an Algorithm:-
STEP I : START.
STEP II : Logically sequence of
problem Solving Steps.
:
STEP X : STOP.
Note : 1. Use START : to start an algorithm.
2. Use END/STOP to end an algorithm.
3. Write solution stepwise.
Algorithm : Points to remember :

■ Use START : to start an algorithm.


■ Use END/STOP to end an algorithm.
■ Write solution stepwise.
■ Use Pseudo code to represent steps in algorithm.
■ Start step with the main action (Use verb) in capital.
■ Represent variables in capital.
■ Each step should be well descriptive.
How to write an algorithm : Example
Algorithm To compute sum and average of two numbers.
STEP I : START.
STEP II : READ two numbers , say A and B.
STEP III : COMPUTE SUM by formula,
SUM := A + B.
STEP IV : COMPUTE AVERAGE by formula,
AVERAGE := SUM / 2.
STEP V : WRITE SUM.
STEP VI : WRITE AVERAGE .
STEP VII : END.
How to write an algorithm : Example
Algorithm : To compute area and perimeter of a rectangle.
STEP I : START.
STEP II : READ length and breadth of a rectangle, say L and B.
STEP III : COMPUTE AREA by formula,
AREA := L * B.
STEP IV : COMPUTE PERIMETER by formula,
PERIMETER := 2 * (L + B) .
STEP V : WRITE AREA.
STEP VI : WRITE PERIMETER .
STEP VII : END.
Flowchart :
■ Definition : Flowchart is a diagrammatical representation of problem
solving steps.
■ Flowchart is expressed by using symbols.
■ Symbols of flowchart have standard shape and meaning.
■ Every two successive steps in a flowchart should be connected in the
proper direction.
Flowchart : symbols
Rectangle with rounded Ends

Parallelogram

Simple Rectangle

Diamond Shaped Box

Arrow

Circle
Flowchart : Symbols :

1. Rectangles with rounded ends :


Represent start or stop of flowchart.
That is, to represent the Beginning and End in a flowchart.
For example :

START STOP
Flowchart : Symbols :

2. Parallelograms :
Represent Input or Output of flowchart.
That is, to represent the READ or WRITE statements in a flowchart.
For example :

READ NUMBER WRITE SUM


Flowchart : Symbols :

3. Simple Rectangle :
Represent Simple Processing of flowchart.
That is, to represent the calculation or formula statements in a flowchart.
For example :

SUM := A + B
Flowchart : Symbols :

4. Diamond Shaped Box :


Represent Decision making statements of flowchart.
That is, to represent the conditions or questions in a flowchart.
For example :

Yes
IS
A>B?

No
Flowchart : Symbols :

4. Arrow :
Represent flow of direction of flowchart.
That is to represent the flow of execution statements in a flowchart.
Every two successive statements in a flowchart should be joined with
arrow.
For example :
SUM := A + B

WRITE SUM
Flowchart : Symbols :
5. Circle : Connector :
Represent how to connect between two parts of flowchart,

Sometimes a flowchart cannot fit at one place / page, then it is continued


on next place / page with a connector.
In such a case, same connector is available on both places / pages.
Generally, a capital letter is used within a connector.
Flowchart : Symbols : Circle : Connector
5. Circle : Connector :
For example :
Part 1 / Page 1 Part 2 / Page 2

READ X, Y A

WRITE SUM
SUM := X + Y

A STOP
FLOWCHART : TO COMPUTE SUM & AVERAGE OF TWO NUMBERS
START

READ A, B

SUM : = A + B
AVERAGE := SUM /2

WRITE SUM, AVERAGE

STOP
FLOWCHART : TO COMPUTE AREA & PERIMETER OF A RECTANGLE
START

READ L, B

AREA : = L * B
PERIMETER := 2 * (L + B)

WRITE AREA,
PERIMETER

STOP
Flowcharts Symbols : Summary :
Symbol Name Symbol Use within a flowchart/ Example 1 Example 2

Rectangle with START/ STOP of a


rounded ends flowchart START STOP

Parallelogram INPUT / OUTPUT of a


flowchart READ L, B WRITE SUM

Simple Rectangle Simple processing/


formula of a flowchart AREA : = L * B I:=1

Diamond shaped box Condition / Decision IS AGE


making structure of a >=18?
flowchart No
Yes
Arrow Flow of direction of a READ L, B
flowchart
AREA : = L * B

Circle Connects two parts of READ L, B A


a flowchart
Algorithms and Flowcharts should be General :

Reason :

1. Algorithms and flowcharts should be free from any programming language.

2. Algorithms and flowcharts should work for n inputs.


Questionnaire:
1. Explain steps of development of computer programming.
2. Define algorithm . Explain with a suitable example.
3. Define flowchart . Explain with a suitable example.
4. Differentiate between algorithm and flowchart.
5. Flowchart and algorithm should be general. Justify the comment.
6. Explain the symbols used in the flowchart :
• Parallelograms
• Rectangle with rounds
• Simple rectangle
• Diamond shaped box
• Arrow
• Circle
Questionnaire:
1. Write an algorithm and draw a flowchart to input a number and compute its
square and cube.

2. Write an algorithm and draw a flowchart to check user is eligible for voting or
not.

3. Write an algorithm and draw a flowchart to compute greater of two numbers.

4. Write an algorithm and draw a flowchart to compute factorial of a number.

5. Write an algorithm and draw a flowchart to compute power of a number.


ALGORITHM : TO COMPUTE SQUARE and CUBE of a number.

STEP I : START.
STEP II : READ a number . say NO.
STEP III : COMPUTE SQUARE by formula,
SQUARE := NO * NO.
STEP IV : COMPUTE CUBE by formula,
CUBE := NO * NO * NO.
STEP V : WRITE SQUARE, CUBE.
STEP VI : END.
FLOWCHART : TO COMPUTE SQUARE and CUBE of a number.
START

READ NO

SQUARE:= NO * NO
CUBE := NO * NO * NO

WRITE SQUARE, CUBE

STOP
Algorithm : To check user is eligible for voting or not.
STEP I : START.
STEP II : INPUT AGE of the user.
STEP III : COMPARE AGE.
IF AGE >= 18 THEN :
PRINT “ Eligible for Voting”
ELSE
PRINT “Not Eligible for Voting”
END IF
[ End Of IF structure.]
STEP IV : END.
Flowchart : TO check user is eligible for voting or not.
START

INPUT AGE

NO
IS AGE
>=18?

YES

WRITE “ELIGIBLE FOR WRITE “NOT ELIGIBLE


VOTING” FOR VOTING”

STOP
ALGORITHM : To compute greater of two numbers.
STEP I : START.
STEP II : INPUT two numbers , say A and B.
STEP III : COMPARE A with B .
IF A > B THEN :
PRINT “ Number1 is greater”
ELSE IF B > A THEN :
PRINT “Number2 is greater”
ELSE
PRINT “NUMBERS ARE EQUAL”
END IF
[ End Of IF structure.]
STEP IV : END.
FLOWCHART : To compute greater of two numbers.
START

INPUT A, B
■ WRIT

YES NO Yes
IS A >B? IS B>A?

NO
WRITE “NUMBER 1 IS WRITE “NUMBERS WRITE “NUMBER2 IS
GREATER” ARE EQUAL” GREATER”

STOP
ALGORITHM : To compute factorial of a number.
STEP I : START.
STEP II : INPUT a number , say NO .
STEP III : SET a counter, say I TO 1 .
STEP IV : SET FACTORIAL TO 1.
STEP V : REPEAT steps VI and VII WHILE I <= NO :
STEP VI : COMPUTE FACTORIAL by formula ,
FACTORIAL := FACTORIAL * I .
STEP VII : INCREMENT I by 1 ,
I := I + 1 .
[End of step V loop.]
STEP VIII : WRITE FACTORIAL .
STEP IX : END.
Flowchart : To compute factorial of a number.
START

INPUT NO

FACTORIAL := 1
I := 1 NO

NO
IS
I<=NO?

YES WRITE FACTORIAL

FACTORIAL := FACTORAL * I
I := I + 1
STOP
ALGORITHM : To compute power of a number.
STEP I : START.
STEP II : INPUT base and exponent , say A and B.
STEP III : SET a counter, say I TO 1 .
STEP IV : SET POWER TO 1 .
STEP V : REPEAT steps VI and VII WHILE I <= B :
STEP VI : COMPUTE POWER by formula,
POWER := POWER * A.
STEP VII : INCREMENT I BY 1 ,
I := I + 1.
[End of step V loop.]
STEP VIII : WRITE POWER.
STEP IX : END.
FLOWCHART : To compute power of a number.
START

INPUT A , B

POWER := 1
I := 1 NO

NO
IS I<=B?

YES WRITE POWER

POWER := POWER * A
I := I + 1
STOP
FYJC
COMPUTER SCIENCE I
CHAPTER
PROGRAM ANALYSIS

Mrs. Pallavi Bhamre


Knowledge is power

You might also like