Sail E0 Webinar
Question


Point out the error in the program.


#include<stdio.h>
int main()
{
const int x;
x=128;
printf("%d\n", x);
return 0;
}
Options:
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
Answer: Option B

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



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers