1.Program Sederhana Membuat Segitiga Siku - Siku :
For i = 1 To x
For j = 1 To i
Print j;
Next j
Print
Next i
Contoh Output :
1
12
123
1234
12345
2.Program Sederhana Membuat Segitiga Siku - Siku versi 2 :
For i = x To 1 Step -1
For j = 1 To i
Print j;
Next j
Print
Next i
Contoh Output :
12345
1234
123
12
1
3.Program Sederhana Membuat Segitiga Siku - Siku versi 3 :
For i = 1 To x
For j = 1 To i
Print i;
Next j
Print
Next i
Contoh Output :
1
22
333
4444
55555
4.Program Sederhana Membuat Segitiga Siku - Siku versi 4 :
For i = x To 1 Step -1
For j = 1 To i
Print i;
Next j
Print
Next i
Contoh Output :
55555
4444
333
22
1
5.Program Sederhana Membuat Segitiga Siku - Siku versi 5 :
For i = 1 To x
For j = i To 1 Step -1
Print j;
Next j
Print
Next i
Contoh Output :
1
21
321
4321
54321
6.Program Sederhana Membuat Segitiga Siku - Siku versi 6 :
For i = x To 1 Step -1
For j = i To 1 Step -1
Print j;
Next j
Print
Next i
Contoh Output :
54321
4321
321
21
1
7.Program Sederhana Membuat Segitiga Sama Sisi :
a=4
b=a
for i = 1 to a
print tab(b);
for j = 1 to i
print "* ";
next j
print
b = b -1
next i
Output :
*
* *
* * *
* * * *
8.Program Sederhana Membuat Segitiga Sama Sisi versi 2 :
a=4
b=1
for i = a to1 step -1
print tab(b);
for j = 1 to i
print "* ";
next j
print
b = b + 1
next i
Output :
* * * *
* * *
* *
*
9.Program Sederhana Membuat Jam Pasir :
a=4
b=1
for i = a to1 step -1
print tab(b);
for j = 1 to i
print " *";
next j
print
b = b + 1
next i
b=a
for i = 2 to a
print tab(b);
for j = 1 to i
print "* ";
next j
print
b = b -1
next i
Output :
* * * *
* * *
* *
*
* *
* * *
* * * *
Sunday, November 20, 2011
Tutorial Qbasic - Perulangan FOR - NEXT
3:38 AM
lutfi
0 comments:
Post a Comment