Using logical operators in loops [closed]

How can I make a while loop take in both arguments and not just one?

My code:

int main()
{
    int a = 1;
    int x = 0;
    while (x == 0 && a == 0)
    {
        std::cout << "text1" << std::endl;
        x++;
    }
    std::cout << "text2" << std::endl;
}

This should printing out text1 all the time (constantly), but it does not. Instead, it skips the whole loop and prints out text2.



Read more here: https://stackoverflow.com/questions/65727052/using-logical-operators-in-loops

Content Attribution

This content was originally published by JuLLe Rq at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: