+ 1
Can any one explain this why output is this until i dont give the value to variable ?
5 Réponses
+ 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.
+ 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.
+ 4
Sachin Saxena Youtuber this behaviour might be compiler dependent.
This link has a better explanation.
https://stackoverflow.com/questions/1597405/what-happens-to-a-declared-uninitialized-variable-in-c-does-it-have-a-value
+ 1
You of course need a base value for the variable j.
0
But here it prints 0 to 10 why