Skip to content

Instantly share code, notes, and snippets.

@tylersamples
Last active December 22, 2015 21:09
Show Gist options
  • Save tylersamples/6531109 to your computer and use it in GitHub Desktop.
Save tylersamples/6531109 to your computer and use it in GitHub Desktop.
int num = 0;
void addOne(int& n)
{
n++;
}
// another way to write addOne
int addOne(int n)
{
return n+1;
}
// so instead of calling addOne(num) it'd be num = addOne(num);
do
{
addOne(num);
} while(num<100);
// in another case
int num = 100;
void addOne(int& n)
{
n++;
}
do
{
addOne(num);
} while(num<100);
// num would end up 101
// basically do is this:
addOne(num);
while(true) {
if(num<100)
return;
addOne(num);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment