Program :-
#include<stdio.h>
main()
{
int num1,num2,m,r,i,flag;
printf("enter two numbers :");
scanf("%d%d",&n1,&n2);
if((num1 - num2 == 2) || (num1 - num2 == 2))
{
for(m = num1 , i =2 ; i <= num1 / 2 ; i++)
{
r = m% i;
if ( r == 0)
flag++;
}
for(m = num2 , i =2 ; i <= num2 / 2 ; i++)
{
r = m% i;
if ( r == 0)
flag++;
}
}
if (flag == 0)
printf("\n the numbers are twin prime");
else
printf("\n the numbers are not twin prime");
}
Output :-
enter two numbers : 17 14
the numbers are not twin prime
No comments:
Post a Comment