Consider the following code segment in C++. How many times for loop will be…

2018

Consider the following code segment in C++. How many times for loop will be repeated? int main() { int f = 1; for (; f; ) cout << "f = " << f++ << "\n"; return 0; }

  1. A.

    10 times

  2. B.

    Not even once

  3. C.

    Repeated forever

  4. D.

    Only once

Attempted by 133 students.

Show answer & explanation

Correct answer: C

Answer: Repeated forever

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs