Write a function to print out all prime numbers in a given range (exclude the upper bound). Each testcase is described as follow:
Input: N M
0 <= N <= 1000
0 <= M <= 1000
Example:
Input: 1 10
Output: 2 3 5 7
Input: 3 5
Output: 3
Input: 24 28
Output:
Note: Print “\n” at the end and don’t print unnecessary characters.
using namespace std;
void print_primenum(int l, int r){
\ To Do
…
…
}
int main(int arg, char** argv){
ifstream ifs;
ifs.open(argv[1]);
int l, r;
try
{
ifs >> l >> r;
print_primenum(l , r);
}
catch (char const* s)
{
printf(“An exception occurred. Exception type: %s\n”, s);
}
ifs.close();
return 0;
}