The problem with yours is that you're printing the result of each trial division. You're printing the (incomplete) results inside the loop. The solution is to move line 22-25 outside the for-loop.
Try something like this:
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
#include <cmath>
int main() {
int input{53};
bool prime = true;
for (int i = 2; (i * i) <= input; ++i)
if (! (input % i)) { prime = false; break; }
std::cout << input << " is" << (prime? "": " not") << " prime.\n";
}
Thanks, your suggestions seems to fix the issue, but I forgot to mention that the program also shouldn't quit and should be able to accept multiple inputs for checking