In one of the exercises in a book I'm reading, I'm asked to trace a person's "profile" according to the year they were born (like those Facebook tests) but in order to limit the possibility of what is typed, I put a if
to signal an error, but even with the value giving if
, the else
block keeps running, how can I solve?
int main(void){
setlocale(LC_ALL,"");
int y,a,b,c;
printf("Digite seu ano de nascimento (quatro digitos)\n");
scanf("%d",&y);
if (y>9999 && y<1000) printf("Ano inválido");
else {
b=y%100;
a=y/100;
c=a+b;
c=c%5;
switch(c){
case 0:printf("Tímido\n"); break;
case 1:printf("Sonhador\n"); break;
case 2:printf("Paquerador\n"); break;
case 3:printf("Atraente\n"); break;
case 4:printf("Irresistível\n"); break;
}
}
return 0;
}