0
The question is, the first question would be if it is reptile and then if it has hull, the answer will be turtle, but even if the answer already appears the algorithm continues, before it closed after finding the answer and I do not know what I did that now does not end (This goes for all).
In this case, that is my only doubt, why does the program not end after finding the answer to each? I’m a beginner so I don’t know any advanced commands.
#include <stdio.h>
int main () {
char respma, respave, respreptil;
char respcasco, respcarn;
char respvoa, resprap, resptrop;
char respqua, respbi, responi;
printf("\nO animal e reptil(s/n)? ");
respreptil = getche();
if (respreptil=='s') {
printf("\nTem casco(s/n)? ");
respcasco = getche();
if(respcasco=='s'){
printf("\nE uma tartaruga");
}
else {
printf("\nE carnivoro(s/n)? ");
respcarn = getche();
if(respcarn=='s'){
printf("\nE um crocodilo");
}
else{
printf("\nE uma cobra");
}
}
}
printf("\nO animal e uma ave(s/n)? ");
respave = getche();
if (respave=='s') {
printf("\nVoa(s/n)? ");
respvoa = getche();
if(respvoa=='s') {
printf("\nE de rapina(s/n)? ");
resprap = getche();
if(resprap=='s'){
printf("\nE uma aguia");
}
else{
printf("\nE um pato");
}
}
else {
printf("\nE tropical(s/n)? ");
resptrop = getche();
if(resptrop=='s'){
printf("\nE um avestruz");
}
else{
printf("\nE um pinguim");
}
}
}
printf("\nO animal e um mamifero(s/n)? ");
respma=getche();
if(respma=='s') {
printf("\nE quadrupede(s/n)? ");
respqua=getche();
if(respqua=='s') {
printf("\nE carnivoro(s/n)? ");
respcarn=getche();
if(respcarn=='s'){
printf("\nE um leao");
}
else{
printf("\nE um cavalo");
}
}
}
getchar();
}