Home » C++ Programming » Loop Types » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    int main()
    {
    int k;
    for (k = 0; k < 20; k++);
    {
    cout << k;
    }
    return 0;
    }
    1. 0
    2. 20
    3. Compilation Error
    4. Runtime Error
    5. None of these
Correct Option: B

for loop with a semicolon is called as body less for loop. It is used only for incrementing the variable values. So in this program the value is incremented and printed as 20.



Your comments will be displayed only after manual approval.