Const

Q1:
Point out the error in the program.
#include<stdio.h>

int main()
{
    const int x;
    x=128;
    printf('%d\n', x);
    return 0;
}

A Error: unknown data type const int

B Error: const variable have been initialised when declared.

C Error: stack overflow in x

D No error

ANS:A - Error: unknown data type const int

A const variable has to be initialized when it is declared. later assigning the value to the const variable will result in an error 'Cannot modify the const object'. Hence Option B is correct



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.