Prime Number between Limits

Description:

"As we all know, Virat Kohli is in the form of his life and hitting centuries has become his habit. Bollywood diva Anushka Sharma is interested in knowing if the number of centuries he would score in two consecutive years would be two consecutive prime numbers (e.g. 7 and 11 ) and successor of sum of both those numbers would also be a prime number p. She gave him numbers n and k and asks if there lie at least k possible values of p between 2 and n. Virat is not a great mathematician and fails to tell her and they broke up on news of which Rohit Sharma is the happiest man on earth. Now, Rohit wants to impress Anushka by giving the answer and doesnt want to take a chance. So, Rohit hires you to write a program for himself that calculates the answer of the question posed by Anushka. Input The only line of input contains two numbers n and k. Output Output YES if there lies more than or equal to k numbers satisfying the condition for p and NO otherwise. Test Case 1 Input (stdin) 10 1 Expected Output NO Test Case 2 Input (stdin) 25 2 Expected Output YES

Program :

#include<stdio.h>

int main()

{

    int n,k,i,j,c,o=0,l,d,p,r=0;

    scanf("%d%d",&n,&k);

    int a[n];

    for(i=3;i<n;i++)

    {c=0;

        for(j=2;j<i;j++)

        {

            if(i%j!=0)

                c++;

        }

        if(c==i-2){

            a[o]=i;

            o++;

        }

    }

    for(l=0;l<o;l++)

    {d=0;

        if((a[l]+a[l+1]+1)<=n)

        {

            for(p=2;p<(a[l]+a[l+1]+1);p++)

            {


                if((a[l]+a[l+1]+1)%p!=0)

                d++;


            }

            if(d==(a[l]+a[l+1]-1))

                r++;

        }

    }

    if(r>=k)

    printf("YES\n");

    else

    printf("NO\n");

    return 0;

}