When you divide 2 numbers in C and the denominator is an integer, the compiler intends it as integer division. Therefore, if you split 1 divided by 2, it returns zero, not 0.5
In addition, your output variable is also an integer, therefore, if you expect decimal outputs, you will not get it.
You can fix this by doing:
float timeLapseInterval = totalLengthSecs / (float) totalFrames;
printf ("\ n \ n% f", timeLapseInterval);
I hope this helps
source share