diff --git a/clockdigital.cpp b/clockdigital.cpp index 724fe0a..c9923f6 100644 --- a/clockdigital.cpp +++ b/clockdigital.cpp @@ -1,30 +1,90 @@ +// C++ program to illustrate the digital +// clock starting from the entered time + +#include #include +#include +#include using namespace std; int main() { - int h, m, s; - cout << "enter the following data " << endl; - cin >> h >> m >> s; - for (h; h < 24; h++) + 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 { - for (m; m <= 59; m++) + while (1) + + // Run Block infinitely { - for (s; s <= 59; s++) + system("cls"); + + // Clear the console + + // Code for Showing Time + for (hour; hour < 24; hour++) { - cout << h << m << s; - if (h < 12) - { - cout << " AM" << endl; - } - else + + for (min; min < 60; min++) { - cout << " PM" << endl; + + 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; } - s = 0; } - m = 0; } - return 0; -} \ No newline at end of file +} diff --git a/clockdigital.exe b/clockdigital.exe new file mode 100644 index 0000000..c75e4b2 Binary files /dev/null and b/clockdigital.exe differ