Another Tricky Problem I am Messing With (Not Homework)



This is a problem I was trying to help a few friends figure out for fun. I
am not sure how to go about this, but there is something I am missing
here. Here is what we want the output to be:
Need to read in a time period from the keyboard (for example 1.2 seconds,
3.4 seconds, or 8.37 seconds). Once the time has been read in, we want to
print out the word ?TICK? and then wait the designated time period and
print the word ?TICK? again. Repeat until there are 6 ?TICK?s on the
screen. It would be real neat if we knew how to variate between TICK and
TOCK, however this might be the output.

Enter a time ==> 2.27
TICK <wait 2.27 seconds>
TICK <wait 2.27 seconds>
TICK <wait 2.27 seconds>
TICK <wait 2.27 seconds>
TICK <wait 2.27 seconds>

Here is what I started, I am lost because I am a newbie lol... This is
wrong any ideas?

[code]
#include <stdio.h>
#include <conio.h>
#include <time.h>

int main( )

{
clock_t start, end;
float total_time;


int i;
int j;
int k;
int timer;

printf("Enter any time in seconds\n ");
scanf ("%i", &timer);
getchar ();

printf( "Start timing\n" );
start = clock();


for ( i=0; i<5000; i++ )
for ( j=0; j<1000; j++ )
for ( k=0; k<100; k++ );


end = clock();

total_time = ( end - start ) / CLK_TCK;
printf("TICK\n");
printf("TICK\n");
printf("TICK\n");
printf("TICK\n");
printf("TICK\n");
printf("TICK\n");
printf( "\nTotal Time Elapsed : %0.3f seconds\n", total_time );

getch();
}
[/code]


--
Message posted using http://www.talkaboutprogramming.com/group/comp.lang.c/
More information at http://www.talkaboutprogramming.com/faq.html

.



Relevant Pages

  • Re: [RFC][PATCH] Experimental enhanced NTP error accounting patch
    ... The ntp code provides the time update per tick: ... That's all the clock code needs from the ntp code (the details of its ... To keep timeofday the same after changing the multiplier we also have to ...
    (Linux-Kernel)
  • Re: Time dilation
    ... an Earth clock as it leaves Earth, travels to a point a fixed distance, ... With telemetry each tick could be uniquely identified. ... The Earth observer measures the time for the 2 way trip as ...
    (sci.physics.relativity)
  • Re: Is Lorentz contraction a real process
    ... >> slowly, by a very small amount, than a precisely similar clock ... > its tick rate, due to their different PERSPECTIVES. ...
    (sci.physics.relativity)
  • Re: Uncle assAl: (SR) Lorentz t, x = Intervals
    ... So you have one clock B and one clock C, both moving inertially, where ... > During acceleration from rest, clock A intercepts n waves corresponding ... > already moving in the inertial frame that A accelerates into, ... Draw lines from every tick from the source ...
    (sci.physics)
  • Re: Uncle assAl: (SR) Lorentz t, x = Intervals
    ... So you have one clock B and one clock C, both moving inertially, where ... > During acceleration from rest, clock A intercepts n waves corresponding ... > already moving in the inertial frame that A accelerates into, ... Draw lines from every tick from the source ...
    (sci.physics.relativity)