Pages

Rabu, 23 Oktober 2013

Contoh Program Pascal kalkulator sederhana

uses crt;
var a,b:integer;
    hasil1:longint;
    hasil2:real;

begin
writeln('kalkulator mini');

write('masukkan bilangan bulat a= ');readln(a);
write('masukkan bilangan bulat b= ');readln(b);
hasil1:=a+b;
writeln('hasil ',a,' + ',b,' = ',hasil1);
hasil1:=a-b;
writeln('hasil ',a,' - ',b,' = ',hasil1);
hasil1:=b-a;



writeln('hasil ',b,' - ',a,' = ',hasil1);
hasil1:=a*b;
writeln('hasil ',a,' * ',b,'= ',hasil1);
hasil2:=a/b;
writeln('hasil ',a,'/ ',b,' = ',hasil2:4:2);
hasil2:=b/a;
writeln('hasil ',b,'/ ',a,' = ',hasil2:4:2);
hasil2:=sqrt(a);
writeln('hasil akar a= ',hasil2:4:2);
hasil2:=sqrt(b);
writeln('hasil akar b= ',hasil2:4:2);
hasil2:=sqr(a);
writeln('hasil pangkat a= ',hasil2:4:2);
hasil2:=sqr(b);
writeln('hasil pangkat b= ',hasil2:4:2);

end.

Related Posts by Categories

0 komentar:

Posting Komentar