Arrenan Ratnaveluppillai Flowcharts

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Read in two numbers P and Q and output the quotient X = P/Q. Include a test to stop if Q = 0.

START

IInput P&Q

Q = 0?

No

Yes
X = P/Q

Output X

STOP

Input X and output the absolute value ABS of X (that is, ABS = X if X >= 0, ABS = -X if X < 0).

START

IInput X

Yes X > 0?

No X = -X

Output X

STOP

Input three numbers I, J, and K. If they are all different, set N=1. If any two of them (but not all three) are the same, set N=2. If all three are the same, set N=3.

3.
Start

Input: I, J, K

Yes? I=J? J=K?

Yes?

No?

No?

Yes?
I=K?

No? Yes? J=K?

No? N=1 N=2 N=3

Output: N

Stop

Input an integer N between 1 and 20 and determine whether it is even or odd by subtracting 2 repeatedly until either 0 or a negative number is reached. If N is even, set M = 0; if N is odd, set M = 1. Start

Input: N

Yes? N>20?

No? Yes? N<1? No?

N=N-2

M=0

Yes? N=0? No?

M=1

Yes? N<0?

No?

Input: N

Stop

Input an integer N greater than 0 and output the sum of all positive integers less than N.

Start

Input: N

Yes? N<0?

No? Sum=0

M=0

Yes? M=N? No? Sum = Sum + M

M=M+1

Output: Sum

Stop

You might also like