Rabu, 27 Februari 2013

Contoh Program tabel Kebenaran

Dibawah ini adalah program tabel kebenaran menggunakan bahasa pemrograman Turbo pascal. Oh ya gak bisa klik kanan yaa?? tenang tenang bisa anda Download Filenya kilk Disini


uses wincrt;
var
 nm_var1,nm_var2,nm_tble1,nm_tble2,kem1,kem2,kem3,kem4:string;
i:integer;
begin
writeln('*----------- Nunik Herawati -----------*');
writeln('*------------- A2.1100153 -------------*');
writeln('*--------------- TI-IIc ---------------*');
writeln('program Tabel kebenaran');
writeln('=========================');
write('nama variable:');readln(nm_var1);
write('nama variable:');readln(nm_var2);
for i:=1 to 4 do
begin
write('nama variable ',i,' [',nm_var1,']:');readln(nm_tble1[i]);
write('nama variable ',i,' [',nm_var2,']:');readln(nm_tble2[i]);
end;
writeln('________________________________________________________________________________');
write(nm_var1:5,'|',
      nm_var2:5,'|',nm_var1:10,'^',nm_var2,'|',nm_var1:10,'V',nm_var2,'|',nm_var1:10,'->',
nm_var2,'|',nm_var1:10,'<->',nm_var2,'|');
writeln;
writeln('________________________________________________________________________________');
writeln;
for i:=1 to 4 do
begin

{premis dan}
if(upcase(nm_tble1[i])='S') or (upcase(nm_tble1[i])='S') or (upcase(nm_tble2[i])='S')
or (upcase(nm_tble2[i])='B') then
kem1:='S';
if(upcase(nm_tble1[i])='B') and (upcase(nm_tble2[i])='B') then
kem1:='B';

{premis atau}
if(upcase(nm_tble1[i])='S') or (upcase(nm_tble1[i])='B') or (upcase(nm_tble2[i])='S')
 or (upcase(nm_tble2[i])='B') then
kem2:='B';
if(upcase(nm_tble1[i])='S') and (upcase(nm_tble2[i])='S') then
kem2:='S';

{jika maka}
if(upcase(nm_tble1[i])='B') and (upcase(nm_tble2[i])='S') then
kem3:='S';
if(upcase(nm_tble1[i])='S') and (upcase(nm_tble2[i])='S') or (upcase(nm_tble2[i])='B') then
kem3:='B';

{jika dan hanya jika}
if(upcase(nm_tble1[i])='B') and (upcase(nm_tble2[i])='B') or (upcase(nm_tble1[i])='S')
and (upcase(nm_tble2[i])='S') then
kem4:='B';
if(upcase(nm_tble1[i])='S') and (upcase(nm_tble2[i])='B') or (upcase(nm_tble1[i])='B')
and (upcase(nm_tble2[i])='S') then
kem4:='S';
writeln(nm_tble1[i]:5,'|',nm_tble2[i]:5,'|',kem1:10,'|',kem2:13,'|',kem3:13,'|',kem4:13,'|');
writeln('==============================================================================');
end;
end.

Tidak ada komentar:

Poskan Komentar