I’ve written this code till now. it is working for some intervals but not for all.
#include<stdio.h>
int main()
{
int a,b,count=1;
printf("Enter lower bound of the interval: ");
scanf("%d", &a);
printf("Enter upper bound of the interval: ");
scanf("%d", &b);
printf("Prime numbers between %d and %d are: ",a, b);
for (int i=a; i<=b; i++)
{
for (int j=2;j<i;j++)
{
if(i%j==0)
{
count=0;
break;
}
}
if(count==1)
{
printf("%d ",i);
}
}
return 0;
}
Please help me identify the error.
New contributor
Chetan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.