This document is a brief example of the commonalities and differences of execution controll in several languages
if (isTrue){
// run some statements
}else{
// run some other statements
}
if (isTrue){
// run some statements
}else{
// run some other statements
}
if (isTrue){
// run some statements
}else{
// run some other statements
}
if isTrue {
// run some statements
}else{
// run some other statements
}
if isTrue:
// run some statements
else:
// run some other statements
if( isTrue ) {
// run some statements
} else {
// run some other statements
}
while (count < 11) {
count++;
}
while (count < 11) {
count++;
}
while (count < 11) {
count++;
}
while count < 11 {
count += 1
}
while (count < 11):
count += 1
while(count < 11) {
count++
}
for(int i=1; i<11; i++){
// run some statements
}
for (int i=1; i<11; i++) {
// run some statements
}
for (int i=1; i<11; i++) {
// run some statements
}
c-style for loop has been removed
has no c-style for loop
for(int i=1; i<11; i++) {
// run some statements
}
for (String item : someList) {
// run some statements
}
for (let item of someArray) {
// run some statements
}
foreach (string item in someList)
{
// run some statements
}
for item in someList {
// run some statements
}
for item in someList:
// run some statements
c++ standard library does not have for each loop
switch (someInt) {
case 1:
// run some code
break;
case 2:
// run some other code
break;
default: break;
}
switch (someInt) {
case 1:
// run some code
break;
case 2:
// run some other code
break;
default: break;
}
switch (someInt) {
case 1:
// run some code
break;
case 2:
// run some other code
break;
default: break;
}
switch someInt {
case 1:
// run some code
case 2:
// run some other code
default:
print("Some other character")
}
has no switch statement
switch(someInt) {
case 1 :
// run some other code
break;
case 2 :
// run some other code
break;
default:
break;
}