[Solved] Changing the if statement into a while statement


For example int A=1; if(A==1){}; is similar to int A=1 while(A!=1).

As already mentioned, your loop is breaking. The above statement is also incorrect.

int a = 1;
if(a == 1) {} //this is true, and will happen once

BUT

int a = 1;
while(a != 1) {} //false on entry, skip loop ( never entered )

You could also consider a switch / case if you can isolate the condition.
This might achieve your goal of removing the ifs, and make the code more readable.

e.g

int a = 1;
while(a)
{
    switch(a)
    {
        case 1: ++a; continue;
        case 2: do();
        default: break;    //end loop
    }
}

solved Changing the if statement into a while statement