I am being asked to generate prime numbers up to an intputted limit from the user. When I input numbers, this program seems to generate number 2 and ODD numbers (both prime and non prime numbers) starting from 3...where did I go wrong?
Also, when I use the same isprime on a different program(which will also be a part of this one) it seems to produce non prime numbers.
In the isprimes function, you have the return statement in the for loop (within else).
Hence, the function returns a value and exits in the first iteration of the for loop.
You can change this in many ways. I would return a bool which I will set to true initially, and then set to false if the if loop is executed once. return the bool after the execution of the for loop.