I LOVE LOMBOK

I LOVE LOMBOK
buat happy ja

Wednesday, September 28, 2011

belajar pemrograman


CONTOH PROGRAM SEDERHANANYA

Quote:
by remaja lombok islan
PROGRAM SEDERHANA:


OUTPUTNYA:


codingnya:
CLS I AS INTEGER
PRINT "Rizki", "1dc01", "Depok"
GOSUB 10
PRINT "Fauzi", "1dc01", "Bogor"
GOSUB 10
END
10 PRINT STRING$<35, "--">
RETURN

Quote:

Contoh Program Menu BIODATA, LUAS SEGITIGA, DERET, EXIT
PROGRAM:

OUTPUNYA:
menu:biodata, luas segitiga, deret, exit



pil 1.biodata


pil 2.Luas Segitiga


pil 3.Deret


pil 4.exit


pada pilihan exit maka program akan langsung keluar "Press any key to continue"

Codingnya:

CLS
DIM a AS INTEGER
LOCATE 5, 23
PRINT "Menu"
LOCATE 6, 20
PRINT "1.Biodata"
LOCATE 7, 20
PRINT "2.Luas Segitiga"
LOCATE 8,20
PRINT "3.Deret"
LOCATE 9,20
PRINT "4.EXIT"
LOCATE 10, 20
INPUT "Mau Pilih Yang Mana?", a
SELECT CASE a
CASE 1
DIM Nama AS STRING, Kelas AS STRING, NPM AS INTEGER
INPUT "Nama =", Nama
INPUT "Kelas =", Kelas
INPUT "NPM =", NPM
PRINT
COLOR 1
PRINT "Nama ="; Nama
PRINT "Kelas ="; Kelas
PRINT "NPM ="; NPM
CASE 2
DIM alas, tinggi AS SINGLE
INPUT "Alas =", a
INPUT "Tinggi =", t
LET L = a * t / 2
COLOR 9
PRINT "Luas Segitiga = a * t / 2 =";L
CASE 3
DIM u AS INTEGER
PRINT
INPUT "Masukan Nilai u=", u
PRINT
FOR x = 1 TO u
FOR y = 1 TO x
COLOR 5
PRINT y:
NEXT y
PRINT
NEXT x
CASE 4
GOTO 500
END SELECT
500 END
Quote:
Originally Posted by remaja lombok island
QBasic, contoh program menu Nama, Kelas, NPM, dan CETAK

PROGRAM:



OUTPUTNYA:

pil 1


pil 2


pil 3


pil 4



sedangkan jika kita pil 5 maka program akan langsung keluar "Press any key to continue"

codingnya:
CLS
DIM P AS INTEGER
10 PRINT "Menu"
PRINT "1.Input Nama"
PRINT "2.Input NPM"
PRINT "3.Input Kelas"
PRINT "4.Cetak Semua"
PRINT "5.EXIT"
INPUT "Pilihan Anda?", P
SELECT CASE P
CASE 1
CSL
DIM NM AS STRING
INPUT "Nama :", NM
GOSUB 10
CASE 2
CLS
DIM NPM AS LONG
INPUT "NPM :", NPM
GOSUB 10
CASE 3
CLS
DIM KLS AS STRING
INPUT "Kelas :", KLS
GOSUB 10
CASE 4
CLS
PRINT "Nama :"; NM
PRINT "NPM :"; NPM
PRINT "Kelas :"; KLS
GOSUB 10
CASE 5
CLS
PRINT "Exit"
END SELECT
END
Quote:
Originally Posted by remaja lombok island

PROGRAM SEGITIGA TERBALIK
PROGRAM


OUTPUTNYA:


Keterangan :

Saat menjalankan program, maka kita akan diminta memasukan angka, lalu akan muncul symbol *(karena di program yang di print adalah “*”) sebanyak angka yang kita masukan.

CODINGNYA:
CLS
INPUT “Masukkan Nilai: “, A
FOR B = A TO 1 STEP -1
FOR C = B TO 1 STEP -1
PRINT “*”;
NEXT
PRINT
NEXT B
END

No comments:

Post a Comment