forked from ratan160/clock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclockdigital.cpp
More file actions
90 lines (74 loc) · 2.08 KB
/
clockdigital.cpp
File metadata and controls
90 lines (74 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// C++ program to illustrate the digital
// clock starting from the entered time
#include <iomanip>
#include <iostream>
#include <stdlib.h>
#include <windows.h>
using namespace std;
int main()
{
system("color 30");
// Background color and Foreground
int hour, min, sec;
cout << setw(70)
<< "*Enter the Current time*\n";
// Use of manipulator for taking
// input from the user
cout << "HH - ";
cin >> hour;
cout << "MM - ";
cin >> min;
cout << "SS - ";
cin >> sec;
// Background color and the
// Foreground for 2nd screen
system("color 5F");
// Cases for the Wrong Time Input
if (hour > 23)
{
cout << "Wrong Time input";
}
else if (min > 60)
{
cout << "Wrong Time Input";
}
else if (sec > 60)
{
cout << "Wrong Time Input";
}
// Otherwise
else
{
while (1)
// Run Block infinitely
{
system("cls");
// Clear the console
// Code for Showing Time
for (hour; hour < 24; hour++)
{
for (min; min < 60; min++)
{
for (sec; sec < 60; sec++)
{
system("cls");
cout << "\n\n\n\n***************"
"************************"
"*********************** "
"Current Time = "
<< hour << ":" << min << ":"
<< sec
<< "Hrs ********************"
"**********************"
"**********************";
// HH:MM:SS columns in output
Sleep(1000);
// Pause for 1 sec
}
sec = 0;
}
min = 0;
}
}
}
}