C++ Program for Prime Number Between 1 to n
1. C++ Program for Prime Number Between 1 to n
In this program, we will ask the user to enter the starting and the ending number so that the compiler will fetch and prints all the prime numbers between those intervals.
Output:

In the above program, the lower interval is assigned to variable low and the highest interval is assigned to the high. So in the output, we have given low as 1 and the high as 10 and the compiler have printed all the prime numbers between 1 and 10.
2. C++ Program for Prime Number Between 1 to n Using Functions
In this program, we will declare a user-defined function to print all the prime numbers between 1 and n.
Output:

After compiling the above program we have given the input n as 15 so the compiler has printed all the prime numbers up to 15.
3. Print Prime Numbers When Greatest Number is Entered first
In this program, we will first give inputs lowest and greatest number between which we want to print all prime numbers.
Output:

4. Printing all Prime Numbers Between 1 and 100
In this program we will print all the prime numbers between 1 and 100.
Output:

Post a Comment