0% found this document useful (0 votes)
229 views5 pages

Beginner's Flowchart Exercises

Uploaded by

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

Beginner's Flowchart Exercises

Uploaded by

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

Jay Dave

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

Input: P and Q

Q =0?
No

Yes

X = P/Q

Output: X

Stop

Jay Dave

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

Input: X

X < 0?
Yes

No

ABS = X

ABS = X * -1

Output: ABS

Stop

Jay Dave 3. 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.

Start

Input: I, J and K

Yes I = K? No Yes Is K = J? No I = J? No

Yes

N=1

N=2

N=3

Output: N

Stop

Jay Dave 4. 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

N = N -2 Yes N > 0?

No No N = 0? Yes M=0 M=1

Input: M

Stop

Jay Dave

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

Start

Input: N

Sum = 0

No N > 0? Yes

I=0

I < N? No Yes

Sum = I + Sum

I = I +1

Output: Sum

Stop

You might also like