ALGORITMA AllAboutboolean
KAMUS
x, y, z : boolean
a : integer
BEGIN
INPUT(a)
x <-- false
z <-- ((3 + (5 mod3)) = 5)
y <-- (a <= 0)
IF ((x and y) or (not(y or z))) THEN
OUTPUT(“Telkom university is The Best”)
ELSE IF ((y and (not z)) or (x and y)) THEN
OUTPUT(“Telkom university is The Clean Campus”)
END IF
OUTPUT(“Telkom university is The Smart Campus”)
END
Jikapenggunamemasukkan -1, maka OUTPUT algoritmatersebutadalah?
Telkom university is The
Smart Campus
program no26 ;
uses crt ;
var
x,y,z : boolean ;
n : integer ;
begin
clrscr ;
write('Input Nilai a =');
readln(n);
x := false ;
z :=((3+(5 mod 3))= 5);
y := ( n <= 0);
if (( x and y) or (not(y or z))) then
writeln('telkom university is the best')
else if (( y and (not z)) or ( x and y)) then
writeln('telkom university is the clean campus');
writeln('telkom university is the smart campus');
readln();
end.
27.Diberikan potongan algoritma sbb :
IF d>0 THEN
d <-- d + 1
ELSE
d <-- 59
IF (m < 0) THEN
m <-- m + 1
ELSE
m <-- 59
j <-- j + 1
ENDIF
ENDIF
OUTPUT(j+m-d)
Jikasecaraberurutannilai j, m dan d adalah 9, 0, dan 0,
makatampilanakhirkode program diatasadalah? 10
program no27 ;
uses crt ;
var
j,m,d,hasil : integer ;
begin
clrscr ;
write('Nilai d = ');
readln(d);
write('Nilai m = ');
readln(m);
write('Nilai j = ');
readln(j);
if d > 0 then
d := d + 1
else
d := 59;
if ( m < 0 ) then
m := m + 1
else
m := 59;
j:= j + 1 ;
writeln(' jika j + m - d , maka hasilnya ? ',hasil);
readln();
end.
28. Diberikan potongan algoritma sbb :
INPUT(N)
IF N>10 THEN
N <-- N + 5
ENDIF
OUTPUT(N)
JikadariperintahINPUT(N), dimasukkan data 5,
makatampilandariOUTPUT(N) adalah… 5
program no28 ;
uses crt ;
var
n : integer;
begin
clrscr ;
write('Masukan Nilai n = ');
readln(n);
if n > 10 then
n := n + 5;
writeln('Maka n Adalah = ',n);
readln();
end.
29. Diberikan potongan algoritma sbb :
Kamus Data
a : integer
b :boolean
Begin
input(a)
bfalse
if (( a = 10 ) && b ) then
output(“First”)
else
output(“Second”)
end if
output(“Third”)
End
Apakah keluaran dari kode program diatas jika pada input(a) dimasukkan nilai 10? Second Third
program no29;
uses crt ;
var
a : integer ;
b : boolean ;
begin
clrscr;
write('Masukan a = ');
readln(a);
b := false ;
if (( a = 10) and b) then
writeln('frist')
else
writeln('second');
writeln('so third is?',a);
readln();
end.
30. Jika y diinputkannilai 16, apakah output darialgoritma di bawahini:
Kamus Data
isFalse: Boolean
y: Integer
BEGIN
Input(y)
isFalse<-- True
If (True) Then
If ( ((y Mod 2) = 0) AND isFalse )
y <-- y Div 3
Else
y <-- y * y
Endif
Else
y <-- 100
Endif
output(y)
END
jawaban = 5
program no30;
uses crt ;
var
isfalse : boolean ;
y :integer ;
begin
clrscr ;
writeln('Input Nilai y = ');
readln(y);
isfalse := true;
if (true) then
if (((y mod 2) = 0) and isfalse) then
y:= y div 3
else
y := y * y
else
y := 100 ;
writeln('maka y adalah? ',y);
readln();
end.
Tidak ada komentar:
Posting Komentar