#include <stdio.h>
isPrime(int n){
for(int i=2;i<=sqrt(n);i++){
if(n%i==0)
return 0;
}
return 1;
}
int main(){
int n1,n2;
printf("enter first number ");
scanf("%d",&n1);
printf("enter second number ");
scanf("%d",&n2);
for(int i=n1;i<=n2;i++){
if(isPrime(i)){
printf("%d ",i);
}
}
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter