Advertisement
dsdeep

PPS Exam Ques -3 Alter

Sep 1st, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     long long int n,r,sum=0;
  6.     int c=0,i,x,pow;
  7.     scanf("%lld",&n);
  8. again:
  9.     r=n%10;
  10.     n=n/10;
  11.     if(r%2!=0)
  12.     {
  13.         if(c==0)
  14.         {
  15.             sum=sum+r;
  16.             c++;
  17.         }
  18.         else
  19.         {
  20.             pow=1;
  21.             for(i=0; i<c; i++)
  22.             {
  23.                 pow=pow*10;
  24.             }
  25.             sum=sum+(r*pow);
  26.             c++;
  27.         }
  28.     }
  29.     if(n!=0)
  30.     {
  31.         goto again;
  32.     }
  33.     /** Prime Check **/
  34.     for(i=1,x=0; i<=sum; i++)
  35.     {
  36.         if(sum%i==0)
  37.         {
  38.             x++;
  39.         }
  40.     }
  41.     if(x<=2&&x>=1)
  42.     {
  43.         printf("\n\t%lld - Prime\n",sum);
  44.     }
  45.     else
  46.     {
  47.         printf("\t%lld - Not Prime\n",sum);
  48.     }
  49.  
  50. return 0;
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement