Loop Types


  1. Which looping process is best used when the number of iterations is known?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    for


  1. How many types of loops are there?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    There are four types of loop. They are the while, do while, nested, for the loop.



  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. View Hint View Answer Discuss in Forum

    NA

    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.


  1. What is the output of this program?
    #include 
    using namespace std;
    int main()
    {
    int num = 20;
    for ( ; ;)
    cout << num;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    There is not a condition in the for loop, So it will loop continuously.