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.
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
0
u mine going thru the code even if the i<10 is false?