Is it important to have conditions like "X++" and "<" in For loop ? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

Is it important to have conditions like "X++" and "<" in For loop ?

22nd Jul 2020, 2:54 AM
Shouvik
Shouvik - avatar
9 Respostas
+ 2
In while loop initialisation done before while loop, condition will be within ( ) and increment or decrement done in while loop Where as for loop initialisation, condition and increment or decrement done in one line in for loop increment or decrement can be done in for loop For loop can be used as while loop But while loop cannot be used as for loop
22nd Jul 2020, 3:04 AM
MANSOOR PASHA
MANSOOR PASHA - avatar
+ 2
No It is not compulsory to use it in for loop
22nd Jul 2020, 2:55 AM
MANSOOR PASHA
MANSOOR PASHA - avatar
+ 2
Yes, my doubt is clear but then how is for loop more useful in coding ?
22nd Jul 2020, 3:06 AM
Shouvik
Shouvik - avatar
+ 1
Are for loop and while loop the same ?
22nd Jul 2020, 2:56 AM
Shouvik
Shouvik - avatar
+ 1
No
22nd Jul 2020, 2:57 AM
MANSOOR PASHA
MANSOOR PASHA - avatar
+ 1
What is the main difference ? For loop and while loop needs to have one condition and other things like "int X =" something or "X++" can be written inside the while loop and can be written inside the ( )- braces of for loop.....
22nd Jul 2020, 3:00 AM
Shouvik
Shouvik - avatar
+ 1
Both are useful for there specific application Where for loop is more convenient because it is written in one line!!
22nd Jul 2020, 3:08 AM
MANSOOR PASHA
MANSOOR PASHA - avatar
+ 1
Ok , thanks for the help
22nd Jul 2020, 3:11 AM
Shouvik
Shouvik - avatar
0
Have you got your doubt clear
22nd Jul 2020, 3:05 AM
MANSOOR PASHA
MANSOOR PASHA - avatar