Skip to content

Instantly share code, notes, and snippets.

@SiddharthManthan
Created March 1, 2022 13:19
Show Gist options
  • Save SiddharthManthan/85c74f56e92b6e7513807110c1e25ac9 to your computer and use it in GitHub Desktop.
Save SiddharthManthan/85c74f56e92b6e7513807110c1e25ac9 to your computer and use it in GitHub Desktop.
#include <iostream>
bool isPrime(int n)
{
bool isPrime = true;
for (int i = 2; i < n; i++)
{
if (n % i == 0)
{
isPrime=false;
}
}
return isPrime;
}
int main()
{
int start{ 0 }, end{ 0 };
std::cout << "Enter Upper and Lower Range : ";
std::cin >> start >> end;
for (int number = start; number <= end; number++)
{
if (isPrime(number))
{
std::cout << number << " ";
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment