Mencari Nilai Max dan Min
mulai :
CLS
N=N+1
INPUT "BILANGAN =" BIL[N]
INPUT "APAKAH ADA DATA LAGI (Y/T)=" J$
IF UCASE$(J$)="Y" GOTO MULAI ELSE GOSUB BESAR : GOSUB KECIL : GOSUB CARI
END
BESAR :
MAX=-999
FOR A=1 TO N
PRINT BIL[A];
IF BIL[A] > MAX THEN MAX=BIL[A]
NEXT A
PRINT "NILAI TERBESAR =" MAX
KECIL :
MIN=999
FOR B=1 TO N
PRINT BIL[B];
IF BIL[B]<MIN THEN MIN=BIL[B]
NEXT B
PRINT "NILAI TERKECIL =" MIN
CARI :
FOR C=1 TO N
IF BIL[C]=15 THEN TEMU=BIL[C]
NEXT C
PRINT "HASIL CARI =" TEMU
END
mulai :
CLS
N=N+1
INPUT "BILANGAN =" BIL[N]
INPUT "APAKAH ADA DATA LAGI (Y/T)=" J$
IF UCASE$(J$)="Y" GOTO MULAI ELSE GOSUB BESAR : GOSUB KECIL : GOSUB CARI
END
BESAR :
MAX=-999
FOR A=1 TO N
PRINT BIL[A];
IF BIL[A] > MAX THEN MAX=BIL[A]
NEXT A
PRINT "NILAI TERBESAR =" MAX
KECIL :
MIN=999
FOR B=1 TO N
PRINT BIL[B];
IF BIL[B]<MIN THEN MIN=BIL[B]
NEXT B
PRINT "NILAI TERKECIL =" MIN
CARI :
FOR C=1 TO N
IF BIL[C]=15 THEN TEMU=BIL[C]
NEXT C
PRINT "HASIL CARI =" TEMU
END
0 komentar:
Posting Komentar