answersLogoWhite

0

I'm not going to write the code for you as it wouldn't be platform independent. However I will show you one possible technique using pseudocode.

Your program will essentially be an infinite loop. In pseudocode, you would use something similar to the following:

X = current_time (in seconds)

repeat

if X and current_time are equal

sleep for 500ms otherwise

let X = current_time

display X (in hours, minutes and seconds)

sleep for 250ms

It is important that your program go to sleep for a short period to reduce the number of comparisons it needs to make and thus reduce the processing time taken up by the program. How you achieve this depends on the operating system, but you cannot use a delay loop because this would consume valuable processing time by itself. In general, the sleep function should inform the operating system to put your program into an idle state for a set period of time. When the timer has elapsed, the OS will waken your program. Thus your program will spend the majority of its time in the idle state.

The sleep period should be less than a second, but must take into account the time it takes to perform the comparison and to display the results. In the code above, the program will sleep for 1/2 a second when there is no change, and 1/4 a second when there is a change. The periods can be adjusted to improve the accuracy of the watch; if they're too high, the clock may periodically jump a second, but too low and the program takes up valuable processing time doing nothing besides checking the current time.

If you're only interested in hours and minutes, then both sleep periods can be increased up to 30 seconds, but for accuracy within a second or so, sleep for 1000ms.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Write a c program which displays digital watch on the screen after taking the hours and minutes from the user?

Write a program which displays digital watch on the screen, after taking the hours and minutes from the user.


What has the author Phillip E Mattison written?

Phillip E. Mattison has written: 'Practical digital video programming with examples in C' -- subject(s): Digital video, Image processing, C (Computer program language), Digital techniques


How can you make C programming on i3i5 processors?

Use a program called visual studio express. Its made by Microsoft and you can program in all kinds of languages. C , C+ etc


How you can make c program of attendance record system?

how can create a attendece sheet in c language


What has the author C Britton Rorabaugh written?

C. Britton Rorabaugh has written: 'DSP primer' -- subject(s): Signal processing, Digital techniques 'Circuit Design and Analysis' -- subject(s): C (Computer program language), Computer-aided design, Data processing, Digital Electric filters, Electric circuit analysis, Electronic circuit design 'Simulating wireless communication systems' -- subject(s): Wireless communication systems, C++ (Computer program language), Computer simulation 'Notes on digital signal processing' -- subject(s): Signal processing, Digital techniques 'Digital filter designer's handbook' -- subject(s): Computer-aided design, Data processing, Digital Electric filters, Electric filters, Digital, Electronic circuit design 'Error coding cookbook' -- subject(s): Debugging in computer science, C (Computer program language) 'Communications formulas & algorithms' -- subject(s): Handbooks, manuals, Mathematics, Telecommunication systems, Telecommunication, Design and construction


How do you make an employee database in c program?

With lots of hard work.


What is watch function in C programming language?

The C language and the standard C runtime toolkit does not contain a watch function, but development tools typically contain a debugger, which normally supports a watch tool.The debugger's watch tool allows to watch the value of a variable changing while stepping through a program. This is one of the most basic and one of the most commonly used debugging tools.


Is that possible to make programme in turbo c for a mini computer having dual core processor-?

Yes, to make a program in Turbo C for a mini computer to have a dual core processor.


Features of c program?

the features of a C program


C program was introduced in the year?

c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.


Program for marksheet in c language?

The std::cout and std::cin streams are peculiar to the C++ standard library. They are not available in the C standard library, but are analogous to stdin and stdout which is in the C standard library.


What is executive a c program?

I think it is 'execution of a C program'.