
Convert Flow Charts to C++
Introduction to Programming
10 Points
Convert the flow charts below into C++ programs. The output of your programs should match the examples below. Turn in a
printout of both .cpp files. You will not receive any credit if the programs do not compile, so you should be certain t hat they
work before making your printouts.
Extra credit: You will receive a bonus point for verifying the number X is greater than one in both programs. If the user enters a
number less than or equal to one, output an error message that tells the user to only enter 2 or above. The program should
then quit without trying to run the invalid X number through the algorithm.
Example output (input is in bold): Example output (input is in bold):
start
stop
Ask for a number
and call it X.
P
๎
1
D
๎
2
Is D > X - 1?
R
๎
Remainder
of X / D.
Is R = 0?
P
๎
0
D
๎
D + 1
Is P = 1?
Answer is
"Yes"
Answer is
"No"
yes no
no
yes
yes
no
Please enter a number:
The number 11 is prime.
Get a number
and call it X
of X/D = 0?
stop
yes
yes no
Please enter a number:
The prime factors of 45 are: 3 3 5