Help! | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 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 Respuestas
+ 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