Variables


  1. Which of the following declaration is not supported by C?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    It is legal in Java, but not in C.


  1. Will the following C code compile without any error?
    #include <stdio.h>
    int main()
    {
    int n;
    {
    int n;
    for (n = 0; n < 12; n++);
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    There can be blocks inside the block. But within a block, variables have only block scope.



  1. Will the following C code compile without any error?
    #include <stdio.h>
    int main()
    {
    for (int n = 0; n < 5; n++);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilers implementing C90 do not allow this, but compilers implementing C99 allow it.


  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    k = 23;
    printf("%d\n", k++);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    Variable k is not defined.



  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    const int k = 11;
    int *p = &k;
    *p = 22;
    printf("%d\n", k);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Changing const variable through non-constant pointers invokes compiler warning.