Berikut ini adalah contoh-contoh program untuk menghasilkan bilangan acak antara 1 - 10
VB / VB.Net / VBS / VBA :
Dim Acak as Integer
Dim Awal as Integer = 1
Dim Akhir as Integer = 10
Randomize()
Acak = CInt( Int( ( Akhir - Awal + 1 ) * Rnd() + Awal ) )
C++ :
#include #include #include using namespace std; int main() { srand((unsigned)time(0)); int acak; acak = (rand()%akhir)+awal; }
Java (updated) :
import java.util.Random;
public final class AcakAcak {
public static void main(String... aArgs){
int awal = 1, akhir = 10, hasil;
Random acak = new Random();
for (int i=1; i<=5; i++){
hasil = (int)((akhir - awal + 1) * acak.nextDouble() + awal);
System.out.println(hasil);
}
}
}
JavaScript :
var awal = 1;
var akhir = 10;
var acak = Math.floor( ( akhir - ( awa - 1 ) ) * Math.random() ) + awal;
PHP :
$awal = 1;
$akhir = 10;
srand(time());
$random = ( rand() % $akhir ) + $awal;
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :