A freepascal clock

Written on 30/08/2008 – 00:47 | by webscriptz |

A basical console clock written in freepascal by me, even if it’s an old language, I have to practice on it for school.

Here you got the code, I’ve added little comments but it isn’t a lot. hh = hour mm = minutes ss= seconds

program clock;

uses crt;

var hh, mm, ss :integer;

BEGIN
ss:=0;
mm:=0;
hh:=0;

writeln(‘Donne le heure: ‘);
readln(hh);
writeln(‘donnez les minutes’);
readln(mm);
clrscr;

while ss<60 do //59 seconds because on 60 mm+1
begin
ss:= ss + 1; //count the seconds

writeln(hh,’ : ‘, mm,’ : ‘, ss);

delay(1);
clrscr;

if ss=59 then //if 59 then mm + 1
begin
mm:= mm + 1;
ss:=0;

if mm=59 then // 60 minutes but 59 minutes and 59 sec => hh+1
begin
hh:= hh + 1;
mm:=0;
ss:=0;

if hh=23 then //24 hr, i don’t do days
begin
hh:=0;
end;
end;

end;
end
END.


related post

Post a Comment

About Me

Here I'll share my knowledge, discovery and experience related to my hobby and work. Most articles on this site are related to blog design, short reviews, tips and make money online. More

Find entries :