This code might be a bit vague, but this question is regarding an assignment I have to turn in and will be checked for plagerism so I will just give the jist of my problem.

bool x = false;

while (x == false)
{


}
if (conditions)
{
x = true;
}
while (x == true)
{
    if (a == b)
    {
    //....
    }
    else
    x = false;
}

I know this code might be confusing but I'll try my best to explain my problem:

Everything runs fine minus the last part. In my second while loop the condition is x == true, but if the conditions of the if statement (within the while statement) arent satisfied, I want x == false, and I want it to go back to the first while loop for the condition x==false. However, it sets x == false, then ends the program.

Any help is appreciated.

You need an outer loop before the while (x == false) loop and after the end of the while (x == true) loop. IE:

while (true)
{
    while (x == false)
    {
    }
    if (conditions)
    {
        x = true;
    }
    while (x == true)
    {
        if (a == b)
        {
            //....
        }
        else
        {
            x = false;
        }
    }
}

You do need to determine if this outer loop needs another terminating condition. IE, this is a "forever" loop.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.