Help! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 Answers
+ 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