468,497 Members | 1,813 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,497 developers. It's quick & easy.

what is the C++ eqivalent of a repeat..until loop?

can someone help me out?
Dec 19 '07 #1
3 12405
romcab
108 100+
I think while loop is fine.

i = 0;
while ( i < 5 )
cout << i;
Dec 19 '07 #2
chroot
13
There is an equivalent to the repeat ... until loop:

int i=0;
do {

++i;
cout << i << endl;

} while (i<10);

There needs to be a ; after while.
I prefer to use the normal while loop when possible, as it's faster to understand than varying while / do while loops.
Dec 19 '07 #3
weaknessforcats
9,207 Expert Mod 8TB
Your choice of loop depends upon whether or not the loop needs to execute at least once. If so, use a do loop. If not, use a while loop.
Dec 19 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by David Callan | last post: by
226 posts views Thread by Stephen C. Waterbury | last post: by
121 posts views Thread by typingcat | last post: by
53 posts views Thread by jaso | last post: by
3 posts views Thread by numlock00 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.