Is a For Loop always executed at least once?

前端 未结 4 1806
栀梦
栀梦 2021-02-20 01:32

According to my teacher, a for-loop always executes at least once, even if the condition is not met.

Example (like I know it from C++):

for (int i=6; i &         


        
4条回答
  •  一整个雨季
    2021-02-20 01:50

    A for-loop always makes sure the condition is true before running the program. Whereas, a do-loop runs the program at least once and then checks the condition.

提交回复
热议问题