in Programming in C edited by
616 views
1 vote
1 vote

What cannot replace ‘?’ in the following C-code to print all odd numbers less than $100$ ?

for (i=1; ? ; i=i+2)
    printf("%d\n", i);
  1. $i\leq100$
  2. $i\leq101$
  3. $i<100$
  4. $i<101$
in Programming in C edited by
616 views

1 comment

Answer should be B.
1
1

1 Answer

0 votes
0 votes
$101$ being the first odd number greater than 100, and from where we do not print further odd numbers.

But option B ensures that $101$ gets printed which we don't want.

So, option B is correct.

Related questions