I cant for the life of me get my loops to work. One part of the loop will be fine, then another wont be fine, and no matter how many times I try to fix it, something goes wrong.
Now this program is meant to determine if a number 1 thru 1000 is a prime number, and if it isnt a prime, to display its divisors. The program is supposed to repeat each time you enter a number. I would also like it so that typing 0 exits the program.
I should also mention that my professor does not want us to use breaks or continues in the loops.
a) The program is supposed to repeat each time you enter a number
b) I would also like it so that typing 0 exits the program.
c) I should also mention that my professor does not want us to use breaks or continues in the loops.
You and your professor need some days off :-)
(Ok, it's just a joke)
Starting from line 22 put that in a while loop and check each variable before asking for another so you dont need to place it into a vector or array. Both however are very simple (especially vectors) and you will most likely be covering it in class the first couple weeks
Yes, once the user enters the single number you want to go through to checks (the if statements) to see if it is prime and also give its divisors. Once that is done the program should loop unless the user enters 0. Also if you need to display all the divisors you can put that section in a while loop as well if youre not comfortable using arrays/vectors