Accept a positive integer and find next prime number to it

#include <stdio.h>
int main()
{
    int i,j,x;
    printf("Enter The Value of X");
    scanf("%d",&x);
    for(i=x+1;i<=x+10;i++)
    {
        for(j=2;j<=i;j++)
        {
            if(i%j==0)
            {
                break;
            }
        }
        if(i==j)
        {
            printf("%d",i);
            break;
        }
    }
   
OUTPUT:

Enter The Value of X
8
11



Comments

Popular posts from this blog

Finding the second largest in an array