+ 1

How to put more than two conditions in for loop?

I typically have doubts how we use continuous expression in for loop e. g. (for int x=0; x>50, x<100; x+=2) or how can we use nested for loops in one statements

17th Oct 2020, 2:45 AM
Aditya
Aditya - avatar
2 Answers
+ 1
If you want the loop to proceed while <x> > 50 and <x> < 100 you can chain the expressions in condition by logical AND operator &&. for(int x = 0; x > 50 && x < 100; x += 2) What operator is used between the expressions is up to the necessity (not always logical AND). (Edit) FYI, considering <x> init by zero, the condition <x> > 50 will not satisfy, and loop won't start.
17th Oct 2020, 3:12 AM
Ipang
0
Add && for(int x=0;x>50&&x<100;x+=2)
17th Oct 2020, 3:29 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar