Thursday, February 16, 2012

Contoh Program Pascal

Berbagi contoh program Pascal for Windows..

Program I : Cacah bilangan


Program Cacah_bilangan;
uses wincrt;
var
   n,i,x,cpos,cneg, cnol : integer;
begin
   clrscr;
   write('cacah Bilangan : ');readln(n);
   cpos:=0;cneg:=0;cnol:=0;
   for i:=1 to n do
     begin
       write('Bilangan ke-',i,' : ');readln(x);
       if x>0 then inc(cpos)
         else if x=0 then inc(cnol)
           else inc(cneg);
     end;
   writeln('Cacah Bil. positif : ',cpos);
   writeln('Cacah Bil. Nol     : ',cnol);
   writeln('Cacah Bil. negatif : ',cneg);
   readln;
end.