+ 1

Help!

Can we declare variables inside while loop just like for loop . Explain with example

12th Jun 2018, 5:02 PM
Aveek Bhattacharyya
Aveek Bhattacharyya - avatar
3 RĂ©ponses
+ 2
I Don't think so
12th Jun 2018, 5:40 PM
Shimon
Shimon - avatar
+ 2
no practically you can't....... but you could define the scope around it so variable gets destroyed I think below example will make more sense if you want: for(int i =something; condition; expression){ } can be replaced with while like.... { int i = something; while(condition){ //inside while loop } }//i will be destroyed at this point.
12th Jun 2018, 5:42 PM
Tanay
Tanay - avatar
+ 1
no
13th Jun 2018, 3:06 AM
$±𝐎â‚č𝔭!𝐹𝓝
$±𝐎â‚č𝔭!𝐹𝓝 - avatar