Orta Düzey Julia
Anthony Markham
Quantitative Developer
for döngüsünden daha az yaygın, ancak bazı durumlarda kullanışlıdır.condition doğru oldukça expression tekrar eder.while condition
expression
end
counter = 10
while counter != 0
print(counter, " ")
counter = counter - 1
end
10 9 8 7 6 5 4 3 2 1
# İlk yineleme
counter = 10
while counter != 0 # burada counter = 10, bu yüzden koşul doğru
print(counter, " ") # counter'ı yazdır, 10'a eşit
counter = counter - 1 # counter'ı 1 azalt
end
10
# İkinci yineleme
counter = 10
while counter != 0 # burada counter artık = 9, bu yüzden koşul doğru
print(counter, " ") # counter'ı yazdır, 9'a eşit
counter = counter - 1 # counter'ı 1 azalt
end
10 9
# Üçüncü yineleme
counter = 10
while counter != 0 # burada counter artık = 8, bu yüzden koşul doğru
print(counter, " ") # counter'ı yazdır, 8'e eşit
counter = counter - 1 # counter'ı 1 azalt
end
10 9 8
counter değişkenini azaltmayı unutursak ne olur?# İkinci yineleme
counter = 10
while counter != 0 # burada counter = 9 olur, bu yüzden koşul doğru
print(counter, " ") # counter'ı yazdır, 9'a eşit
end
10 10 10 10 10 10 10 10 10
Orta Düzey Julia