Int value only decreasing once | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Int value only decreasing once

if my code is this: health = health - 5 and my base health is 50 then however manytimes i cout "health" its still 45 why

26th Apr 2018, 4:08 PM
Nislo Mislo
Nislo Mislo - avatar
3 Réponses
+ 2
If you only perform the operation once, five will be substracted only one time. Thus, it is correct that 'health' is 45. The Variable health = The value of health - 5 -> health = 50-5 health is 45 and will not change anymore until you want it to.
26th Apr 2018, 4:18 PM
D B
D B - avatar
0
yes but i subtract it twice in the same code and it is stil saying that it is 45
26th Apr 2018, 4:47 PM
Nislo Mislo
Nislo Mislo - avatar
0
can you schow us the code then?
26th Apr 2018, 4:55 PM
Paul