Code:
#include<stdio.h>
main()
{
int noprime=0, num=2, count=0;
int primes,test1,firstP;
printf("How many twin primes do you want to find?");
scanf("%d",&primes);
while(count<primes){
noprime=0;
for(test1=1;test1<num;test1++){
if(num%test1==0){
noprime=1;
break;
}
if(noprime){
printf("%d is not prime\n",num);
num++;
}
else{
if(num-firstP==2){
printf("%d is a prime and a twin prime in the prime pair %d%d\n",num,firstP,num);
firstP=num;
num++;
count++;
}
else{
printf("%d is prime but not a twin prime\n",num);
firstP=num;
num++;
}
}
}
}
}
