- 2
What's the purpose of that "int total= 0;"?
14 Respostas
+ 3
declare a total variable of type int to store total value
+ 2
It declares and initializes the integer variable total to 0.
0
it initialise total with 0 value and when all operations are done we get new value ..
we always need starting point .. in this case 0 is the starting point for "total".
0
it initializes the total to 0
0
To declare and initalise total.
0
Standard initialization
- 2
"total += x;" increments the variable total by the value of x.
- 2
so what's its output then?
- 2
ohhhh, okay thank you đ
- 2
"total += x;" --> total = total + x
- 3
how about that "total += x;"?
- 3
same as total=total+x;
- 3
the output is like the updated value of total
- 3
in order to store the result of an expression into the total, first we have to intialize the value of total to zero.