yeh you should really try to make and pseudocode algorith first then you can worry about the code.
if you would tell us exactly what u want would be easier for us to help.
here is a tip though using the time.h header
int totalTime=0;
time_t start,end;
time(&start);
.
. // do code here or loop till you want it to stop
.
time(&end);
totalTime = end-start;
totalTime will then contain the time in seconds between the start and end