edited by
5,810 views
13 votes
13 votes

How many times is the comparison $i \geq n$ performed in the following program?

int i=85, n=5;
main() {
    while (i >= n) {
        i=i-1;
        n=n+1;
    }
}
  1. $40$
  2. $41$
  3. $42$
  4. $43$
edited by

5 Answers

Answer:

Related questions

744
views
2 answers
4 votes
go_editor asked May 27, 2016
744 views
Consider the code below, defining the functions $f$ and $g$:f(m, n) { if (m == 0) return n; else { q = m div 10; r = m mod 10; return f(q, 10*n + r); } } g(m, n) { if (n ...
2.2k
views
3 answers
7 votes
go_editor asked May 27, 2016
2,189 views
Suppose we have constructed a polynomial time reduction from problem $A$ to problem $B$. Which of the following can we infer from this fact?If the best algorithm for $B$ ...
554
views
1 answers
3 votes
go_editor asked May 27, 2016
554 views
There is a thin, long and hollow fibre with a virus in the centre. The virus occasionally becomes active and secretes some side products. The fibre is so thin that new si...
597
views
2 answers
5 votes
go_editor asked May 27, 2016
597 views
Consider the code below, defining the functions $f$ and $g$:f(m, n) { if (m == 0) return n; else { q = m div 10; r = m mod 10; return f(q, 10*n + r); } } g(m, n) { if (n ...