Skip to content

Instantly share code, notes, and snippets.

@philpoore
Created November 22, 2015 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philpoore/934e03e05ac5277b8205 to your computer and use it in GitHub Desktop.
Save philpoore/934e03e05ac5277b8205 to your computer and use it in GitHub Desktop.
Examples of loops in diffrent languages
Each example prints the numbers 0 --> 9 inclusive.
// Javascript
for (var i = 0; i < 10; i += 1){
console.log(i);
}
// Java
for (int i = 0; i < 10; i += 1){
System.out.println(i);
}
// c
int i;
for (i = 0; i < 10; i++){
printf(i);
}
// c++
for (int i = 0; i < 10; i++){
cout << i << endl;
}
// python
for i in range(0, 10):
print i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment