+ 1

why sum =0

14th Jul 2016, 12:56 PM
Swati Singh
Swati Singh - avatar
3 odpowiedzi
+ 6
simply because sum will have garbage value in it before you put anything. If your variable sum has garbage(random number) your addition will go wrong. thats why sum = 0
14th Jul 2016, 1:42 PM
vishal narang
vishal narang - avatar
+ 2
if u use int sum instead of int sum = 0 sum+=... will cause error
14th Jul 2016, 1:00 PM
tomorrow's never coming
tomorrow's never coming - avatar
+ 1
this is because we are declaring the initial value of sum which will increase as vsriables are added to it.
15th Jul 2016, 1:53 PM
pranav
pranav - avatar