🔒 Closed count down

Status
Not open for further replies.

Murrzz

Honorary Poster

#include <stdio.h>
#include <time.h>


int main ()
{


unsigned int x_hours=0;
unsigned int x_minutes=0;
unsigned int x_seconds=0;
unsigned int x_milliseconds=0;
unsigned int totaltime=0,count_down_time_in_secs=0,time_left=0;

clock_t x_startTime,x_countTime;
count_down_time_in_secs=10; // 1 minute is 60, 1 hour is 3600


x_startTime=clock(); // start clock
time_left=count_down_time_in_secs-x_seconds; // update timer

while (time_left>0)
{
x_countTime=clock(); // update timer difference
x_milliseconds=x_countTime-x_startTime;
x_seconds=(x_milliseconds/(CLOCKS_PER_SEC))-(x_minutes*60);
x_minutes=(x_milliseconds/(CLOCKS_PER_SEC))/60;
x_hours=x_minutes/60;




time_left=count_down_time_in_secs-x_seconds; // subtract to get difference


printf("\n %d ",time_left);
system("cls");
}


printf( "\n\n\n ok Time's ut\n\n\n");
getch();

return 0;


}
 
Status
Not open for further replies.

About this Thread

  • 1
    Replies
  • 371
    Views
  • 2
    Participants
Last reply from:
pixkit

Trending Topics

Online now

Members online
1,152
Guests online
3,230
Total visitors
4,382

Forum statistics

Threads
2,331,290
Posts
29,257,149
Members
1,149,525
Latest member
allan220
Back
Top