Loops


  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    int p = 0, k = 0, q;
    for (k = 0; k < 10; k++)
    {
    p++;
    if (k == 9)
    break;
    }
    printf("%d",p);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    10


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int p = 0, k = 0, q = 1;
    for (k = 0; k < 10; k++)
    {
    p++;
    q++;
    continue;
    }
    printf("%d, %d", p, q);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    10, 11



  1. Which keyword can be used for coming out of recursion?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    return


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int k = 0;
    while (k = 0)
    printf("Veg...\n");
    printf("Non-Veg...\n");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Non-Veg...



  1. How many times while loop condition is tested in the following C code snippets, if k is initialized to 0 in both the cases?
    while (k < m)
    k++;
    ————-
    do
    k++;
    while (k <= m);











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    m+1, m+1