Jay Dave Flowchart Assignment
Jay Dave Flowchart Assignment
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?
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