0

prime number between a range no output is showing

#include<stdio.h> void main() { int a,b,i,j,count=0; printf("enter any range to find prime number between it"); scanf("%d %d",&a,&b); for(i=a;i<=b;i++) { for(j=2;j<=i/2;j++) { if(i%j==0) { count++; } } if(count==0) { printf("%d",i); } } }

13th Oct 2019, 6:58 PM
sagar gupta
sagar gupta - avatar
1 Respuesta
+ 1
you need to reset count back to 0 at the start of every iteration of the outer-loop 😄
13th Oct 2019, 7:10 PM
Anton Böhler
Anton Böhler - avatar