Prime numbers between 2 numbers

Program:

#include<stdio.h>
#include<conio.h>
void main(void)
{
int n1,n2,i,flage;
printf("\n Enter a number:");
scanf("%d",&n1);
printf("\n Enter a number:");
scanf("%d",&n2);
printf("\nPrime number between %d and %d is:",n1,n2);
for(i=1+1;i<n2;++i)
{
flage=check_prime(i);
if(flage==0)
printf(" %d ",i);
}
}
int check_prime(int num)
{
int j,flage=0;
for(j=2;j<=num/2;++j)
if(num%j==0)
{
flage=1;
break;
}
return flage;
}

Output:

 Enter a number:2
 Enter a number:5
Prime number between %d and %d is:2  3  5

Comments

Popular posts from this blog

Stack

Operation on Single Linked List

EXTRA INFORMATION ABOUT TECHNOLOGY