APC-PRAC-034.c (1055B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* Take a Range as input from user and print the prime number between it. */ 8 /* Auhtor: Amit Dutta, Date: 20-11-2025 */ 9 10 // This code has not been compiled. 11 // If you find any issues, please create a new issue on GitHub regarding them. 12 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues 13 14 #include <stdio.h> 15 #include <math.h> 16 17 int isPrime(int); 18 19 int isPrime(int n) 20 { 21 if (n <= 1) 22 return 0; 23 if (n == 2) 24 return 1; 25 if (n % 2 == 0) 26 return 0; 27 int temp = (int)sqrt(n), i; 28 for (i = 3; i <= temp; i += 2) 29 if (n % i == 0) 30 return 0; 31 return 1; 32 } 33 34 int main() 35 { 36 int lb, ub, i; 37 printf("Enter the lower bound and the upper bound: "); 38 scanf("%d %d", &lb, &ub); 39 printf("\nPrime numbers between %d and %d: ", lb, ub); 40 for (i = lb; i <= ub; i++) 41 if (isPrime(i)) 42 printf("%d ", i); 43 return 0; 44 }