Write Time format function in C#

3600 sec should be converted to 1hr:0min:0sec

Showing Answers 1 - 6 of 6 Answers

#include<stdio.h>
#include<conio.h>
void main()
{
int seconds,hours,minutes,input;
clrscr();
printf("Enter number of seconds: ");
scanf("%d",&input);
hours=input/3600;
minutes=input%3600;
seconds=minutes%60;
minutes=minutes/60;
printf("TIME: %dh:%dm:%ds",hours,minutes,seconds);
getch();
}

  Was this answer useful?  Yes

maheshcp

  • Aug 17th, 2010
 

static void timers(long x) A
{
long h,m,s,temp; t
h = m = s = temp = 0;
h= x / 3600;
if (x % 3600 != 0)
{
temp=x%3600;
 m = temp / 60;
if (temp % 60 != 0)
{
s = temp % 60;
}
}
Console.WriteLine("{0}hr:{1}mm:{2}s", h, m, s);
}


  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions