Multiple conditions in a 'do while' loop | Sololearn: Learn to code for FREE!
+ 1

Multiple conditions in a 'do while' loop

I have been trying to use the logical operator "&&" but I am not sure how to use it in my code(this is in C) do { // do something } while((8<height)&&(1>height)); height is an int which is an input

11th Sep 2020, 9:16 AM
David Yadav
David Yadav - avatar
2 Answers
+ 4
If both are true block will execute. its possible you have them the wrong way round as height is the changing variable while(height > 1 && height < 8){doSomthing}; if height equals a number between 2 and 7 this will execute.
11th Sep 2020, 9:22 AM
D_Stark - avatar
+ 3
Logical AND operator. If both the operands are non-zero, then the condition becomes true.
11th Sep 2020, 9:24 AM
A S Raghuvanshi
A S Raghuvanshi - avatar