Tuesday 16 January 2018

Time calculation using function

Q : Write a function that takes time in seconds as input and prints it in terms of hours, minutes and seconds.

Solution : 

/*==============================
     Girfa Student Help
     Program : Time calculation using function
     More Program :http://girfahelp.blogspot.in/p/function-programming.html
================================*/
#include<stdio.h>
#include<conio.h>
void time(int);
void main()
{
     int s,h,m;

     clrscr();
     printf("Enter second>> ");
     scanf("%d",&s);
     time(s);
     getch();
}
void time(int s)
{
     m=s/60;
     h=m/60;
     m=m-(h*60);
     s=s-((s/60)*60);
     printf("\n\t%d : %d : %d",h,m,s);
}


No comments:

Post a Comment