Variables


  1. Which of the following format identifier can never be used for the variable var?
    #include <stdio.h>
    int main()
    {
    char *variable = "Advanced Training in C by interviewmania.com";
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    %c can be used to print the indexed position.
    %d can still be used to display its ASCII value.
    %s is recommended.
    %f cannot be used for the variable var.


  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. Which of the following cannot be a variable name in C?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    volatile is C keyword.


  1. What will be the output of the following C code?
    #include <stdio.h>
    void fun(const int *);
    int main()
    {
    const int k = 12;
    printf("%d ", k);
    fun(&k);
    printf("%d", k);

    }
    void fun(const int *k)
    {
    *k = 21;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Cannot change a const type value.



  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.