##### How many times is the comparison i ≥ n perform...

How many times is the comparison i ≥ n performed in the following program?

```
int i=85, n=5;
main() {
while (i >= n) {
i=i-1;
n=n+1;
}
}
```

40 | |

41 | |

42 | |

43 |

How many times is the comparison i ≥ n performed in the following program?

```
int i=85, n=5;
main() {
while (i >= n) {
i=i-1;
n=n+1;
}
}
```

40 | |

41 | |

42 | |

43 |

The value of i − n is 80 initially. We run the loop as long as i − n ≥ 0 and in each iteration, i − n decreases by 2. Just before the kth time the comparison is performed (for k ≥ 1), the value of i−n is 80−2k+2. Hence just before the forty-first comparison, the value of i − n is 0. After the forty-first comparison, the loop is executed one last time. We need to make the comparison once more to exit the loop. Thus the correct answer is 42.