bsc

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

APC-PRAC-022.c (1463B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 12 Dec 2025
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* Write a program to accept a number and check whether the number is twisted prime or not */
      9 // File Name - amit0711202504.c (LAB), APC-PRAC-022.c (Local)
     10 
     11 // This code has not been compiled.
     12 // If you find any issues, please create a new issue on GitHub regarding them.
     13 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
     14 
     15 #include <stdio.h>
     16 #include <math.h>
     17 #include <stdbool.h>
     18 
     19 bool checkPrime(int num)
     20 {
     21     if (num < 2)
     22         return false;
     23     if (num == 2)
     24         return true;
     25     if (num % 2 == 0)
     26         return false;
     27     int limit = (int)sqrt(num);
     28     for (int i = 3; i <= limit; i += 2)
     29         if (num % i == 0)
     30             return false;
     31     return true;
     32 }
     33 
     34 int reverseNumber(int num)
     35 {
     36     int reverse = 0;
     37     while (num > 0)
     38     {
     39         reverse = (reverse * 10) + (num % 10);
     40         num /= 10;
     41     }
     42     return reverse;
     43 }
     44 
     45 int main()
     46 {
     47     int num;
     48     printf("Enter the number : ");
     49     scanf("%d", &num);
     50     if (!checkPrime(num))
     51     {
     52         printf("\nInput %d is not a prime number.", num);
     53         return 0;
     54     }
     55     if (checkPrime(reverseNumber(num)))
     56         printf("\nInput %d is a twisted prime number.", num);
     57     else
     58         printf("\nInput %d is not a twisted prime number.", num);
     59     return 0;
     60 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror