c 2b 2b timer

Solutions on MaxInterview for c 2b 2b timer by the best coders in the world

showing results for - "c 2b 2b timer"
Julieta
15 Sep 2016
1# include <windows.h>
2# include <iostream>
3using namespace std;
4
5void timer(int sec)
6{
7    Sleep(sec*1000);
8}
9
10int main()
11{
12    cout << "Wait 5 seconds " << endl;
13    timer(5);
14    cout << "FireWorks !" << endl;
15
16    return 0;
17}
Yannik
16 Jan 2018
1#include <iostream>
2#include <chrono>
3
4// This is how to measure the time it takes functions to finish
5
6long add(int a, int b) {
7	return a + b;
8}
9
10int main() {
11	auto start = std::chrono::steady_clock::now();
12	std::cout << "9 + 10 = " << add(9, 10) << '\n';
13	auto end = std::chrono::steady_clock::now();
14	std::chrono::duration<double> elapsed_seconds = end - start;
15	std::cout << "elapsed time to compute 9 + 10: " << elapsed_seconds.count() << "s\n";
16	return 0;
17}
Angelina
07 Sep 2017
1// CPP program to create a timer 
2#include <iomanip> 
3#include <iostream> 
4#include <stdlib.h> 
5#include <unistd.h> 
6using namespace std; 
7
8// hours, minutes, seconds of timer 
9int hours = 0; 
10int minutes = 0; 
11int seconds = 0; 
12
13// function to display the timer 
14void displayClock() 
15{ 
16	// system call to clear the screen 
17	system("clear"); 
18
19	cout << setfill(' ') << setw(55) << "		 TIMER		 \n"; 
20	cout << setfill(' ') << setw(55) << " --------------------------\n"; 
21	cout << setfill(' ') << setw(29); 
22	cout << "| " << setfill('0') << setw(2) << hours << " hrs | "; 
23	cout << setfill('0') << setw(2) << minutes << " min | "; 
24	cout << setfill('0') << setw(2) << seconds << " sec |" << endl; 
25	cout << setfill(' ') << setw(55) << " --------------------------\n"; 
26} 
27
28void timer() 
29{ 
30	// infinte loop because timer will keep 
31	// counting. To kill the process press 
32	// Ctrl+D. If it does not work ask 
33	// ubuntu for other ways. 
34	while (true) { 
35		
36		// display the timer 
37		displayClock(); 
38
39		// sleep system call to sleep 
40		// for 1 second 
41		sleep(1); 
42
43		// increment seconds 
44		seconds++; 
45
46		// if seconds reaches 60 
47		if (seconds == 60) { 
48		
49			// increment minutes 
50			minutes++; 
51
52			// if minutes reaches 60 
53			if (minutes == 60) { 
54		
55				// increment hours 
56				hours++; 
57				minutes = 0; 
58			} 
59			seconds = 0; 
60		} 
61	} 
62} 
63
64// Driver Code 
65int main() 
66{ 
67	// start timer from 00:00:00 
68	timer(); 
69	return 0; 
70} 
71
queries leading to this page
c 2b 2b countdown timertimer cppc 2b 2b function timerhow to make timer c 2b 2bmake timer in c 2b 2bhow to implement timer in c 2b 2btimer in cppmake timer c 2b 2bhow to set up a timer in c 2b 2bcpp runtime timerc 2b 2b simple timertimer function in c 2b 2bhow to have a timer in c 2b 2bc 2b 2b timerset timer c 2b 2bhow timer works in c 2b 2bc 2b 2b set timerstart timer c 2b 2bcpp timeeradd timer c 2b 2badd a timer c 2b 2bhow to set timer in c 2b 2btimer c 2b 2b classhow to create an timer in c 2b 2b 23define timer c 2b 2bhow to set a timert in c 2b 2bhow to make a timer with c 2b 2ba timer system in c 2b 2bc 2b 2b code run timerhow to set timer c 2b 2b 23define timer c 2b 2b explainedjavascript timer in c 2b 2btimer using struct c 2b 2bc 2b 2b timer codec 2b 2b timer countdownmake a timer c 2b 2bhow to make timer in cppcpp timergive a function timer c 2b 2bhow to add timer in c 2b 2b programc 2b 2b timer classhow to code timer in c 2b 2bhow to design a timer in c 2b 2btimer using structure c 2b 2bc 2b 2b how use timeradd timer in c 2b 2bc 2b 2b cout timerc 2b 2b how to make timerc 2b 2b how to set up a timerc 2b 2b loop timertimer in c 2b 2bcpp timercpptimer c 2b 2btimer in c 2b 2b exampletimer code in c 2b 2bc 2b 2b make a timerhow i can make timer c 2b 2bc 2b 2b how to make a timerc 2b 2b clock timerchrono timer c 2b 2bimplement timer in c 2b 2bshow timer c 2b 2bhow to make a timer in c 2b 2bc 2b 2b simple function timerc 2b 2b windows timerusing a timer in c 2b 2bhow to create a timer in c 2b 2ba timer in c 2b 2bc 2b 2b code timerhow to set a timer in c 2b 2bclock timer c 2b 2bc 2b 2b timer