my English is poor but that's okay ...
I'm doing a free introductory course to the Pascal
I need to do a program that I type the time in seconds and it shows in days, hours, minutes and seconds but this happening the following error, some results appear negative
this is the code
for example if I type 150000Code:program tempo; uses crt; var aux, aux1, aux2, s, m, h, d : integer; t : longint; begin clrscr; writeln('******* Digite o tempo em segundos *******'); readln(t); d := t div (86400); aux := t mod (86400); h := aux div (3600); aux1 := aux mod (3600); m := aux1 div 60; aux2 := aux1 mod 60; s := aux2; writeln('Dias ', d); writeln('Horas', h); writeln('Minutos ', m); writeln('Segundos ', s); readln; end.
Dias = 1
Horas = 0
Minutos = -32
Segundos = -16
thanks



Reply With Quote