-2
My code is only printing the last case. Could someone help me?
My Code...
include<stdio.h>
int main(){
int teste,total,i;
float percentpop,percentgeral,percentarq,percentcad,renda,pop,geral,arq,cad;
scanf("%d",&teste);
for(i=1;i<teste;i++){
scanf("%d %f %f %f %f",&total,&percentpop,&percentgeral,&percentarq,&percentcad);
pop=total*(percentpop/100);
geral=(total*(percentgeral/100))*5;
arq=(total*(percentarq/100))*10;
cad=(total*(percentcad/100))*20;
renda=pop+geral+arq+cad;
}
for(i=1;i<teste;i++){
printf("A RENDA DO JOGO N. %d E = %.2f\n",i,renda);
}
return 0;
}
Face your variables are overwritten during the loop, the printing should be done at the end of each iteration, or you should guard-lás and show afterwards...
– MSLacerda
The statement presented in image form is not very useful, particularly for mobile devices. It would be better to put the same in the form of text facilitating the reading to all.
– Isac