+ 2

What's the difference between the two? I gues both codes mean the same then why do I get an error?? Can anyone explain it to me?

https://code.sololearn.com/cZen583jRc96/?ref=app https://code.sololearn.com/csD09xrhAdlL/?ref=app

6th Aug 2020, 6:09 PM
Sneh Chauhan
Sneh Chauhan - avatar
4 Answers
+ 3
It ia not same. In abc2 integer i is undefined in print function(since integer i is declarated in loop scope and function print is out of loop scope) In second example you declare integer i before loop scope and function print and integer i is in the same scope In both examples loop for has no commands since ; in the end of the line
6th Aug 2020, 6:17 PM
george
george - avatar
+ 3
Yeahh that's correct... I got it... Thanks😊
6th Aug 2020, 6:18 PM
Sneh Chauhan
Sneh Chauhan - avatar
+ 3
Ohh... I was not known to that thing... Thanks for the knowledge 😇😊
6th Aug 2020, 6:24 PM
Sneh Chauhan
Sneh Chauhan - avatar
+ 2
Sneh Chauhan i remember that in visual studio 10 there was a setting named loop for scope and it was by default false. And this settings gives possibility to make abs2 example correct. But after VS12 this settongs become true by default and make error!!
6th Aug 2020, 6:21 PM
george
george - avatar