bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / tuition-c / APC-PRAC-034.c

APC-PRAC-034.c (919B)


      1 /* Take a Range as input from user and print the prime number between it. */
      2 /* Auhtor: Amit Dutta, Date: 20-11-2025 */
      3 
      4 // This code has not been compiled.
      5 // If you find any issues, please create a new issue on GitHub regarding them.
      6 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
      7 
      8 #include <stdio.h>
      9 #include <math.h>
     10 
     11 int isPrime(int);
     12 
     13 int isPrime(int n)
     14 {
     15     if (n <= 1)
     16         return 0;
     17     if (n == 2)
     18         return 1;
     19     if (n % 2 == 0)
     20         return 0;
     21     int temp = (int)sqrt(n), i;
     22     for (i = 3; i <= temp; i += 2)
     23         if (n % i == 0)
     24             return 0;
     25     return 1;
     26 }
     27 
     28 int main()
     29 {
     30     int lb, ub, i;
     31     printf("Enter the lower bound and the upper bound: ");
     32     scanf("%d %d", &lb, &ub);
     33     printf("\nPrime numbers between %d and %d:  ", lb, ub);
     34     for (i = lb; i <= ub; i++)
     35         if (isPrime(i))
     36             printf("%d  ", i);
     37     return 0;
     38 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror