I need some help with this program, on the for. Next, I need to print the prime numbers within this range A and B determined by the user, the problem is that the program only printed a number within that range. And also show whether or not there is a prime number within the range. Thanks in advance if anyone can help.
#include<stdlib.h>
#include<stdio.h>
main(){
int a, b, div=0;
printf("Digite o numero a:\n");
scanf("%d",&a);
if (a>=0 && a<=100){
printf("Numero a esta entre 0 e 100\n",a);
}else{
printf("Nao esta entre 0 e 100, digite novamente:\n", a);
while(a>100){
printf("Numero ivalido, digite novamente: \n");
scanf("%d", &a);
}
}
printf("Digite o numero b:\n");
scanf("%d",&b);
if (b>=0 && b<=100){
printf("Numero b esta entre 0 e 100\n",b);
}else{
printf("Nao estao entre 0 e 100, digite novamente:\n",b);
while(b>100){
printf("Numero invalido, digite novamente: \n");
scanf("%d",&b);
}
}
for(int i=a+1;i<b;i++){
if(div%i==0){
div++;
printf("%d\n",i);
}
}
if(div==2){
printf("Sem numeros primos no intervalo");
}
}