Constants


  1. What will be the output of the following program:-
    #include
    int main()
    {
        const int a=34;
        int b=128;
        a = b;
        printf("%d\n",a);
        return 0;
    }
    









  1. View Hint View Answer Discuss in Forum

    const is a type specifier, when used with a data type, its value cannot be modified

    Correct Option: C

    Compiler marks a as read only, any attemp to modify the value will generate compiler error.


  1. What will be the output of the following C code?
    #include <stdio.h>
    int const Result()
    {
    printf("interviewmania.com");
    return 0;
    }
    void main()
    {
    Result();
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    interviewmania.com



  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int const m = 10;
    m++;
    printf("m is %d", m);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Constant variable has to be declared and defined at the same time. Trying to change it results in an error.


  1. Which of the following statement is false?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Since the constant variable has to be declared and defined at the same time, not doing it results in an error.



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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Since the pointer m is declared to be constant, trying to assign it with a new value results in an error.