Unit I Program Logic Development
Unit I Program Logic Development
Unit I Program Logic Development
1.0 Introduction
1 of 10
A program is a sequence of instructions for performing a specific task.
Process of developing a program involves finding a solution to a complex
problem. To do so, there is a need of tools which enable programmer to represent
logic required in the program. Before solving any given problem we have to first
think about logical steps for finding one of the solutions for that problem. These
logical steps can be represented using different ways as
- Algorithm
- Flowchart
1.1 Algorithm
1.3 Flowchart
4 of 10
• Start / End (Terminal symbol)
• Process box
• Decision box
• Connector
• Manual Operation
5 of 10
Some sample flowcharts are given here.
START
INPUT A
INPUT B
C=A*B
DISPLAY C
END
START
INPUT A
IF
Yes A MOD 2 No
=0
END
6 of 10
Example 3: Displaying first n natural numbers. (Iterative constructs)
START
INPUT N
I=1
IF No
I <= N
Yes
DISPLAY I
I=I+1
END
7 of 10
Example 4: Finding greatest of three numbers
START
INPUT A
IF
A > B AND Yes
A>C
No
DISPLAY A is greatest
IF
B > A AND Yes
B>C
No
DISPLAY B is greatest
IF
C > A AND Yes
C>B
No
DISPLAY C is greatest
END
8 of 10
Example 5: Determining whether given number is prime or not
START
INPUT N
I=2
IF No
I<N
Yes
IF
Yes
N MOD I
=0
No
I=I+1
END
Sample Questions
10 of 10