Variables


  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. 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>
    int main()
    {
    int Eighteen = 18;
    int eighteen = 15;
    printf("%d", eighteen);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Variable names Eighteen and eighteen are both distinct as C is case sensitive.


  1. What is the problem in following variable declaration?
    float 2B-H-K?;











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    A variable name cannot start with an integer, along with that the C compiler interprets the ‘-‘ and ‘?’ as a minus operator and a question mark operator respectively.



  1. What will happen if the following C code is executed?
    #include <stdio.h>
    int main()
    {
    int var = 15;
    printf("%d", var);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    It will run without any error and prints 15.