+ 1

Can any one explain this why output is this until i dont give the value to variable ?

https://code.sololearn.com/cgf3coLsZd2s/?ref=app

6th May 2020, 10:36 AM
Sachin Saxena
Sachin Saxena - avatar
5 Respostas
+ 6
An uninitialized variable is a variable that is declared but is not set to a definite known value before it is used. ... The 'sum' variable wasn't assigned an initial value, and now it contains some "garbage". In some cases, if you're lucky enough, it may also be set to zero enabling the function to work correctly. ~Via Google.
6th May 2020, 10:52 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 4
That is a while loop that runs if condition is true. Condition here is, j should be less than or equal to 10. That means while loop will run until value of j is 11, because 11 is neither less than nor equal to 10. In the body of loop, we are printing whatever the value of variable j is. And after printing it, we increment variable by 1.
6th May 2020, 10:46 AM
Raj Chhatrala
Raj Chhatrala - avatar
6th May 2020, 10:54 AM
Avinesh
Avinesh - avatar
+ 1
You of course need a base value for the variable j.
6th May 2020, 10:46 AM
M Tamim
M Tamim - avatar
0
But here it prints 0 to 10 why
6th May 2020, 10:50 AM
Sachin Saxena
Sachin Saxena - avatar