0
What is the point of changing the value of the variable once it is declared?
we declare first eg. int a=100; then we change the value in the next step. a=50. why is the reduced value displayed in the output. and what is the point of changing the values..?
2 odpowiedzi
+ 12
Variables are called so because they are subjected to change during program flow. This is the most basic and essential building block of your programs. E.g.
int sum = 0;
int num = 1;
int i = 0;
while (i < 5)
{
sum += num;
i++;
}
In the above section of a program you can see that variable sum and variable i both change values for each loop iteration, respectively for their specific purposes.
The examples in the slides are just to show you how variables are altered.
+ 3
variables are for values that tend to change like when you log into a site it says welcome username with username being the variable