Last active
December 22, 2015 21:09
-
-
Save tylersamples/6531109 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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