this is the program in question:
#include <stdio.h>
#include <tgmath.h>
#include <simpio.h>
long main(){
long cars_t,years;
cars_t=80000;
years=0;
while (cars_t<=160000){
cars_t=ceil(cars_t*(1+7/100));
years+=1;
}
printf("Xronia:%ld\n",years);
printf("Arithmos Autokinhton:%ld\n",cars_t);
}
Just an extremely simple program with a while function. But for some reason it doesn't give any output at all. What i have noticed however is that, the moment i remove the while function(and the code inside of it) the program runs perfectly fine. Can anyone tell me how to fix this? thanks in advance.
cars_t*(1+7/100)this is a pretty slow rate of growth to start with, but regardless,7/100equals0due to integer division,1 + 0=1, and thus you are simply assigning the value ofcars_tto itself and it likely isn't even increasing. To avoid this, at least docars_t=ceil(cars_t*(1+7.0/100))main()should beint.