min_sec.c
This commit is contained in:
parent
4ceaaf7f37
commit
cdf74c227d
24
c05_expression/min_sec.c
Normal file
24
c05_expression/min_sec.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define SEC_PER_MIN 60
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int sec, min, left;
|
||||||
|
|
||||||
|
printf("Convert seconds to minuts and seconds!\n");
|
||||||
|
printf("Enter the number of seconds (<=0 to quit):\n");
|
||||||
|
scanf("%d", &sec);
|
||||||
|
|
||||||
|
while (sec > 0)
|
||||||
|
{
|
||||||
|
min = sec / SEC_PER_MIN;
|
||||||
|
left = sec % SEC_PER_MIN;
|
||||||
|
printf("%d seconds = %d:%d\n", sec, min, left);
|
||||||
|
printf("Enter next value (<0 to quite):\n");
|
||||||
|
scanf("%d", &sec);
|
||||||
|
}
|
||||||
|
printf("Done!\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user