Twin Prime Number

Twin Prime Numbers are numbers who have a difference of two and both of the numbers are Prime Numbers.

Example 1: 3 and 5. 5-3 = 2. Also 3 and 5 both are Prime Numbers. Hence they are Twin Prime Numbers.

Example 2: 3 and 7. 7-3 = 4. Here though 3 and 7 both are Prime Numbers their difference is not two. Hence they are not Twin Prime Numbers.

C
#include <stdio.h>
#include <math.h>
int main() 
{
    int n1=0,n2=0,flag=0;
    printf("Enter first number: ");
    scanf("%d",&n1);
    printf("Enter second number: ");
    scanf("%d",&n2);
    if(abs(n1-n2)==2)
    {
        for(int i=1;i<=n1;i++)
        {
            if(n1%i==0)
            {
                flag++;
            }
        }
        if(flag==2)
        {
            flag=0;
            for(int i=1;i<=n2;i++)
            {
                if(n2%i==0)
                {
                    flag++;
                }
            }
            if(flag==2)
            {
                printf("%d and %d are Twin Prime Numbers",n1,n2);
            }
        }
    }
    if(flag!=2)
    {
        printf("%d and %d are not Twin Prime Numbers",n1,n2);
    }
    return 0;
}
C