Introduction
In this blog, I am going to explain how to calculate the seconds, minutes and hours by using the given second.
Software Requirement
Turbo C++ or C.
Programming
- #include < stdio.h >
- #include < conio.h > void main()
- {
- int sec, hr = 0, min;
- clrscr();
- printf("\n Enter seconds:");
- scanf("%d", & sec);
- min = sec / 60;
- sec = sec % 60;
- if (min >= 60)
- {
- hr = min / 60;
- min = min % 60;
- }
- if (hr != 0)
- {
- printf("\n No of hours:%d", hr);
- printf("\n No of minutes:%d", min);
- printf("\n No of seconds:%d", sec);
- } else if (hr == 0)
- {
- printf("\n No of Minutes:%d", hr);
- printf("\n No of seconds:%d", min);
- }
- getch();
- }
Explanation
In the programming, given above, I explain in a clear manner, how to print the hours, seconds and minutes.
Output
Conclusion
Thus, it is a program for calculating the hours, minutes and seconds by using the given seconds, which can be executed and printed successfully.