Another Tricky Problem I am Messing With (Not Homework)
- From: "joebenjamin" <guitarguy70@xxxxxxxxxxx>
- Date: Mon, 10 Sep 2007 12:20:51 -0400
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
.
- Follow-Ups:
- Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Miguel Guedes
- Re: Another Tricky Problem I am Messing With (Not Homework)
- Prev by Date: Re: Sizes of Integer Types
- Next by Date: Re: Anyone have any ideas on this one.....Thanks tolkien
- Previous by thread: can't replace define to const
- Next by thread: Re: Another Tricky Problem I am Messing With (Not Homework)
- Index(es):
Relevant Pages
|