samedi 21 août 2021

Random Number in Fortran

I am learning Fortran and I would like to make a little game to practice the input. The objective is to find the good number, who is a random one. I made a code to generate the number but my problem is that, the result is a random number, but it's always the same. For example, when I execute the code 3 times, it print 21 the three times.

Here is my code :

program find_good_number
    integer :: random_number
    integer :: seed
    seed = 123456789
    call srand(seed)
    random_number = int(rand(0)*100)
    print*, random_number
end program find_good_number

Can you help me please ? Thanks




Aucun commentaire:

Enregistrer un commentaire