Q: Write A program to input two number and check whether its is Twisted Twin Prime Number or not?

Explanation : Two Number said to be twisted twin prime number if gap between given number is 2 and Prime, Reverse prime

Ex : 11-13

### Solution :

/* ################################

Girfa Student Help

Twisted Twin Prime number

(11-13=11-31)

for more visit :
http://girfahelp.blogspot.in/p/c-language.html

##########################

######
*/

#include<stdio.h>

#include<conio.h>

int prime(int);

int rev(int);

void main()

{

int n1,n2;

clrscr();

printf("Enter Two
Number>> ");

scanf("%d%d",&n1,&n2);

if((n2-n1==2) &&
prime(n1) && prime(n2) && prime(rev(n1)) &&
prime(rev(n2)))

{

printf("\nGiven Numbers
are Twisted Twin Prime");

}

else

printf("Input is not
Twisted Twin Prime Number");

getch();

}

/* Check
whether provided number is prime or not */

int prime(int n)

{

int b;

for(b=2;b<n;b++)

{

if(n%b==0)

break;

}

if(b==n)

return(1);

else

return(0);

}

int rev(int n)

{

int r,sum=0;

while(n>0)

{

r=n%10;

sum=sum*10+r;

n=n/10;

}

printf("\n\t%d\n",sum);

getch();

return(sum);

}

## No comments:

## Post a comment