# How to find estimated total time, based on time elapsed and bytes downloaded?

I'm doing C programming exercise for college, and couldn't figure out how to calculate the following value based on four values (2 of each from one type of variable). The exercise is to write a program for a progress bar for downloading a file.

Given values/variables:

• time: the current time
• totalBytes: the total file size in bytes

The program needs to calculate the Elapsed_Time, Percent_Completed, Download_Speed, Total_Time and Remaining_Time.

I can't figure out the formula for Total_Time. That is the estimated total time to download the file.

I used this, but didn't work:

(time - startTime) / (totalBytes - bytes)

Any help is appreciated. Cheers

-

You have spent time-startTime downloading bytes. So you would estimate the rate of download as $\frac {\text{bytes}}{\text{time-startTime}}$. Then the total estimated time is totalBytes divided by this. $\text {Total_Time}=\frac{\text{totalBytes(time-startTime)}}{\text{bytes}}$

-