Homepage » C / C++

C / C++ Courses ? 12 (Do/While and Comparison of Loops)

5 September 2011 1,665 views No comments

After a long time, i have started to continue this course. Because i got some mails which want me to complete this course. Even if there is someone who benefits this course, it is enough for me to be willing to complete. Let’s continue then;)


Let’s try one example with 3 different loops that we have learned before. Also this example will remind us how to use loops.

(1) int x=1;




(2) for(int x=1; x<=10; x++)


(3) do{




(1) , (2) and (3) makes exactly the same thing, but do/while is a bit different. For this example, they have no difference. This loop will execute at least one time even if the condition is false. First it executes, then checks the condition. If you dunno that it will execute at least once, don’t use do/while!

That’s enough for do/while loops. See you soon! 😉

Ziynet Nesibe


Any comments are welcome.

Etiketler: , , , , ,