How do you make multiple conditions for the while loop? Example: loop while the variable a = 1 and the variable b = 2?
How do you make multiple conditions for the while loop? Example: loop while the variable a = 1 and the variable b = 2?
Like this.
The loop will continue as long as a is 1 and b is 2.Code:while (a==1 && b==2) { ... }
Thanks
Oh and how about or? Such as a=1 or b=2?
To loop while a is 1 or b is 2 or both conditions are met would be
There are some tutorials that cover these things at this site.Code:while (a==1 || b==2) { ... }
If you have a C++ book, 'conditionals' are usually covered with if-statements, so you might look there.How do you make multiple conditions for the while loop?
Or "logical operators", because that's what && and || are.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law