Build a better website in less than an hour with GoDaddy
Ad Get started today for FREE! no tech skills required. Get found on Google and top sites like Facebook

Do ... while structure improvement

Sometimes the use of jumps such as: continue break goto call is necessary to avoid the execution of some instructions.

We suggest this improvement as a replacement for tricks like for(;;) if(condition)break; and jumps.

//allow initializers (extra improvement)
do(bool condition=0){
 //block A
 //block B & initializer still visible

Example print arrays separating its elements

This code prints the content of an array, separating each of its elements by a comma, avoiding the printing of a comma after the last element.

using namespace std;

int main(){
 unsigned a[]={0,1,2,3,4,5,6,7,8,9};
 do(unsigned b=0){
 return 0;

Example auxiliary variables remain unchanged after last cycle

Sometimes a loop requires auxiliary variables, which change each cycle, but after the last one, they must either remain unchanged or it is useless to change them.

int main(){
 unsigned int loop1=0;
 unsigned int loop2;
 unsigned int result=0;
 unsigned int auxiliary1=1,auxiliary2=2,auxiliary3=3;
  //allow initializers (extra improvement)
   //auxiliaries remain unchanged
 return 0;