I have a price for a car, let's say 10000. I want to apply a 20% sale to this price.
I have a struct
in which auta->cena
is a float
.
int year, i, n=0, pocet=1, sale;
scanf(" %d", &year);
scanf(" %d", &sale);
for(i=1; i<=pocet; i++){
if(year == auta->rok){
++n;
pocet++;
auta->cena *= ((float)(100 - sale) / 100); //calculate price after 20% sale
//temp = ((int)(temp * 100 + 0.5)) / 100.0; //use this formula to round up final price, it doesnt work, I get 0.00
printf("%.2f\n", auta->cena);
}
auta = auta->dalsi;
}
I am not good at converting—can anyone explain it to me, please? How should I go about it?