Green University of Bangladesh
Department of Computer Science and Engineering
(CSE)
Faculty of Sciences and Engineering
Semester: (Summer, Year: 2022), [Link]. in CSE (Day)
Course Title: Structured Programming Lab
Course Code: CSE 104 Section: 221 - DN
Lab Project Name: Digital Clock
Student Details
Name ID
1. Heaven Bawm 221902015
Submission Date: 3rd September, 2022
Course Teacher’s Name: Mahbubur Rahman
Lecturer
Department of CSE
Green University of Bangladesh
[For Teachers use only: Don’t Write Anything inside this box]
Lab Project Status
Marks: ………………………………… Signature: .....................
Comments: .............................................. Date: ..............................
1|P a g e
Table of Contents
Chapter 1: Introduction 3-4
1.1 Introduction
1.2 Listed of Equipment used
1.3 Design Goals/Objectives
Chapter 2: Implementation of the project 5-8
2.1 Implementations
2.2 Screenshots
Chapter 3: Conclusion 9
3.1 Learning Outcome
3.2 Future Scope
References 9
2|P a g e
Chapter 1
Introduction
1.1 Introduction
A digital clock is a type of clock that displays the time digitally (i.e. in
numerals or other symbols), as opposed to an analogue clock.
Digital clocks are often associated with electronic drives, but the "digital"
description refers only to the display, not to the drive mechanism. Both
analogue and digital clocks can be driven either mechanically or
electronically, but "clockwork" mechanisms with digital displays are rare.
Typically, it is possible to make digital clock using C language for the
whole design you require, but using components as pre-programmed blocks
to perform simple tasks is a intelligent and professional way to solve a
design problem.
3|P a g e
1.2 Listed of Equipment used
✓ Laptop
✓ IDE: Codeblocks
✓ C language
1.3 Objectives
➢ To detect these states and adjust alarm time to the best possible
moment, when people are in awaking state or in light sleep.
➢ To display the time digitally in 24 hour format as HH:MM:SS.
➢ To build a digital clock successfully gaining all the required
knowledge.
➢ To apply our knowledge and understanding into practice.
➢ To know about the working of each and every component and their
role.
4|P a g e
Chapter 2
Implementation of the project
2.1 Implementations
A digital clock is a type of clock that displays the time digitally in numerals.
This project is about to generate a digital clock using c program. Below the
flowchart of the digital clock is given.
Figure: Flowchart of digital clock
5|P a g e
The source code of the project is:
1 #include <stdio.h>
2 #include <time.h> //for sleep() function
3 #include <unistd.h>
4 #include <stdlib.h>
5 int main()
6 {
7 int Hour, Min, Sec;
8 scanf("%d%d%d", &Hour, &Min, &Sec);// Input the current time
9 while(1)
10 {
11 system("cls");// It clears the screen
12
13 printf("Clock: Hour : Minute : Second\n");
14 printf(" %02d : %02d : %02d ",Hour,Min,Sec);
15
16 fflush(stdout);//clear output buffer in gcc
17
18 Sec++;
19
20 //update hour, minute and second
21 if(Sec==60)
22 {
23 Min+=1;
24 Sec=0;
25 }
26 if(Min==60)
27 {
28 Hour+=1;
29 Min=0;
30 }
31 if(Hour==24)
32 {
33 Hour=0;
34 Min=0;
35 Sec=0;
36 }
37
38 sleep(1);//It waits for one second
39 }
40 return 0;
41 }
6|P a g e
2.2 Screenshots
In this program, user take the input of hour, minute and second. Using
increment and nested loop in the program it will be executed and show the
output of the digital clock.
7|P a g e
In the output of the program, if the seconds hit 60 then the minute will increase
by 1 and after the minute reach 60 then the hour will be increase by 1.
8|P a g e
Chapter 3
Conclusion
4.1 Learning Outcome
From this assignment, I have learnt to implement a few C concepts in the future
projects such as loops, nested loops, conditional statements, increment and
decrement in the program. I have learnt to create flow chart for explaining the
project. I have also gain some knowledge of IDE: codeblocks and also trying
other IDE for better coding in the future.
4.2 Future Scope
❖ Helps us to broaden our knowledge.
❖ The scope of studying is quite large; from application of software
compilers to hardware.
References
1. “DEPATISnet | DEPATISnet- Startseite” [Link]. Retrieved
2021 -11 - 08
2. US2768332A, Protzmann, Donald E.; Phaneuf, Edgar A. & Doyle,
Malcolm G., "Timing device", issued 1956-10-23
9|P a g e