Example: Prime Numbers Between two Intervals
Output
Enter two positive integers: 12 55 Prime numbers between 12 and 55 are: 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53
To print all prime numbers between two integers, theĀ check_prime() function is created. This function checks whether a number is prime or not.
All integers between n1 and n2 are passed to this function.
If a number passed to check_prime() is a prime number, this function returns true, if not the function returns false.
If the user enters the larger number first, this program will swap the numbers. Without swapping, this program won't work.