sachin bhikule
sachin bhikule

Reputation: 23

Multiple conditions in for loop statement

for (icnt = 1; icnt <= (ino1 / 2) && (ino2 / 2) ; icnt++)

and

for (icnt = 1; icnt <= (ino1 / 2) && icnt <= (ino2 / 2) ; icnt++)

Both for loops gives same output still then what is the difference between both statements ? I tried to find out flow of program, can someone explain me what is the difference

Upvotes: 1

Views: 54

Answers (1)

chqrlie
chqrlie

Reputation: 144550

Both loops iterate the same number of times only by chance, probably because ino1 <= ino2.

The first loop iterates while icnt <= ino1 / 2 and ino2 / 2 != 0, which is very different from the second loop condition where icnt must be less or equal to both ino1 / 2 and ino2 / 2.

Upvotes: 1

Related Questions