continue break goto call
is necessary to avoid the execution of some instructions.for(;;) if(condition)break;
and jumps.//allow initializers (extra improvement)
do(bool condition=0){
//block A
}while(condition){
//block B & initializer still visible
}
#include<iostream>
using namespace std;
int main(){
unsigned a[]={0,1,2,3,4,5,6,7,8,9};
do(unsigned b=0){
cout<<a[b];
}while(++b<10){
cout<<',';
}
cout<<endl;
return 0;
}
int main(){
unsigned int loop1=0;
unsigned int loop2;
unsigned int result=0;
unsigned int auxiliary1=1,auxiliary2=2,auxiliary3=3;
while(loop1++<1000000000){
//allow initializers (extra improvement)
do(loop2=0){
result+=auxiliary1;
result-=auxiliary2;
result*=auxiliary3;
}while(++loop2<10){
//auxiliaries remain unchanged
auxiliary1+=auxiliary3;
auxiliary2*=auxiliary1;
auxiliary3-=auxiliary2;
}
}
return 0;
}