0
I’m a beginner in C language, I’m doing an activity that is to register students and averages in a double-chained list, everything is working, however I believe I’m using too many ifs, there is some way to do these conditions without using so many ifs?
A part of the code:
int editar(aluno *alunoPtr){
aluno *tmp;
int edita, aux=0;
tmp=alunoPtr->prox;
if(vazia(alunoPtr)){
printf("A LISTA ESTA VAZIA!!!\n");
}else{
printf("Numero de matricula: ");
scanf("%i", &edita);
while(tmp){
if(edita == tmp->matricula){
printf("\nMedia final: ");
scanf("%f", &tmp->mediaFinal);
if(tmp->mediaFinal >= 0 && tmp->mediaFinal <= 10){
printf("\nMEDIA CADASTRADA COM SUCESSO!\n");
}else{
printf("\nMEDIA INVALIDA!\n");
};
aux++;
break;
};
tmp=tmp->prox;
};
if(aux==0){
printf("\nNUMERO DE MATRICULA INVALIDO!\n");
};
};
};