Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 77 additions & 17 deletions clockdigital.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,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()
{
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;
}
}
Binary file added clockdigital.exe
Binary file not shown.