Coders Packet

C++ program to Print all Prime Numbers in an Interval

By Aalok Kumar

Hello buddies, here is a c++ program for printing all prime numbers between two numbers.

In my program, the first line of input asks for a (start of interval).

The second line of output asks for (end of interval).

For each number i between and b, the program checks that the number is prime or not.

If found prime then it prints the number.

Note: While traversing, skipping even numbers is better as even numbers are not prime(except 2).

Here is the sample output of my program:

Enter the start of the interval: 20

Enter the end of the interval: 95

Output: 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 


Download Complete Code


No comments yet