What is the difference between for-loop and if-else statements | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between for-loop and if-else statements

23rd Feb 2017, 3:07 PM
MASTER OF COMPUTER
2 Answers
+ 7
For-Loop is an looping statement and If-Else is Conditional statement.
23rd Feb 2017, 3:57 PM
Mr.Robot
Mr.Robot - avatar
0
They're two completely different things. When you use a for loop, the code inside it executes until the condition of the loop is true. When you use if-else, if the condition is true you run the code inside the "if", otherwise you run the code inside the "else", but only once.
23rd Feb 2017, 3:15 PM
Marco Bimbati
Marco Bimbati - avatar