0

URGENT: need help with for loops

Let’s say you execute a for loop successfully... for (int i=0; i<10; i++) Now I want it to do one more pass of loop even though it doesn’t satisfy the statement i<10. How can I do this? The programming I’m working on right is way to long and complex to explain it fully but I am stuck on this problem. In brief I’m running the for loop until I reach a negative number but I need to run the loop one more time to display the negative number.

24th Sep 2018, 11:24 PM
Seth
2 Answers
+ 8
Seems like you need to execute the loop body once even if the condition is false. You can use do..while loop for this, since do..while loop checks the condition after execution. Sample code: https://code.sololearn.com/ciy3OknrJK00/#cpp
25th Sep 2018, 3:12 AM
Shamima Yasmin
Shamima Yasmin - avatar
0
u mine going thru the code even if the i<10 is false?
25th Sep 2018, 12:33 AM
Isaac
Isaac - avatar