Computer Science EngineeringVery hard

How many times does c++ execute in: int c=0; for(int i=1;i<=100;i*=3) c++;

  1. A. 5
  2. B. 4
  3. C. 6
  4. D. 34

Correct answer: A. 5

i takes the values 1, 3, 9, 27 and 81 before reaching 243, which exceeds 100.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic