top of page
Wave
Cactus%20Plant_edited.jpg

TWIN PRIME NUMBER

#include<stdio.h>
int check_prime(int n)
{
    int i;
    if(n<2)
        return 0;
    for(i=2;i<=n/2;i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}
int main()
{
    int i,a,b;
    printf("Enter the lower bound: ");
    scanf("%d",&a);
    printf("\nEnter the upper bound: ");
    scanf("%d",&b);
    printf("\nTwin prime numbers are:\n\n");
    for(i=a;i<=b;i++)
    {
        if(check_prime(i)&&check_prime(i+2))
        printf("(%d,%d) ",i,i+2);
    }
    return 1;
}

Subscribe Form

Thanks for submitting!

  • Facebook
  • YouTube
  • Instagram
  • Twitter

©2020 by Abhisek Midya ( A18 )

bottom of page