0
Isn't a variable can be changed during program run time?
so why do we write for example int my age=34 why do we write the number while it can.be changed during run time?
1 Réponse
+ 1
A completely fictitious example, but suppose the length of a fish when it is hatched is 1 cm. Then we could do this:
float fish_length = 1.0f;
//the letter f casts the double 1.0 to a float
Then, if the fish grows by 0.1 cm increments we can use this later in code to make the fish grow:
fish_length += 0.1f;
//which is equivalent to fish_length = fish_length + 0.1f;