Xiang
01-22-2003, 03:49 PM
Dear sir,
I want to write a program that accepts a number of seconds and converts it to days, hours, minutes and seconds. Why my output is not correctly?
#include <stdio.h>
#include <conio.h>
void main()
{
int seconds;
clrscr();
printf("How many second?\n");
scanf("%i", &seconds);
printf("Day: %i\n", seconds/(60*24));
seconds=seconds%(60*24);
printf("Hours: %i\n", seconds/60);
seconds=seconds%60;
printf("Minutes: %i\n", seconds/60);
seconds=seconds%60;
printf("Seconds: %i\n", seconds/1);
getch();
}
Thanks
Xiang
I want to write a program that accepts a number of seconds and converts it to days, hours, minutes and seconds. Why my output is not correctly?
#include <stdio.h>
#include <conio.h>
void main()
{
int seconds;
clrscr();
printf("How many second?\n");
scanf("%i", &seconds);
printf("Day: %i\n", seconds/(60*24));
seconds=seconds%(60*24);
printf("Hours: %i\n", seconds/60);
seconds=seconds%60;
printf("Minutes: %i\n", seconds/60);
seconds=seconds%60;
printf("Seconds: %i\n", seconds/1);
getch();
}
Thanks
Xiang