All the Primes Between N1 and N2

Medium

Read two integers N1 and N2 and print every prime from N1 to N2 inclusive on one line in the form primes between 10 and 30: 11 13 17 19 23 29, with single spaces and no trailing space. If there are none, print no primes between 24 and 28 instead. Nest the prime test from the previous exercise inside a loop over the candidates, resetting the flag for each one. If N1 is greater than N2 print N1 must not exceed N2 and return 1; if N2 is greater than 1000000 print N2 must be at most 1000000 and return 1. If the two integers cannot be read, print invalid input and return 1.

Success Criteria

Your code must pass 8 test case(s) to complete this exercise. 3 hint(s) are available if you need help.

How did you find this exercise?

Your rating helps us improve the content.

Sign in to track your progress

You can work on exercises as a guest, but sign in to track your progress and save your submissions.

This platform is built by its community

Every lesson, project, and tool on HelloC++ is funded by sponsors. Join them and help shape what we build next.

Become a Patron