You are given two positive integers L and R. Now print the prime numbers between L to R.
Note: Assume that 1 is a prime number
Input Format
The first line will contain T, the number of test cases. Each test case contains two positive integer L and R Constraints
0 < T <= 20 1 <= L,R <= 100 and where L < R Output Format
Print the prime numbers between L to R.
int main()
{
int t, i, j;
scanf("%d", &t);
for (i = 0; i < t; i++) {
int l, r;
scanf("%d %d\n", &l, &r);
while (l < r) {
for (j = 2; j < l / 2; j++) {
if (l % j != 0) {
printf("%d ", l);
}
l += 1;
}
}
}
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}
It takes input but doesnt return any value. I tried and could not fix it. Can anyone explain what is wrong with the code? And to offer suggestions to fix it please. Thanks.