If we use const variable instead of #define, we can specify the scope of the variable.
1)CONST is a keyword in c++. 2)If a variable is declared as const the value of the variable will not change through out the program. 3)example: void main() { clrscr(); const a=40; for(int i=0;i<=100;i++) a++; cout<<a;//a=40; } in the above program the output will be 40.
Declaring a const variable instead of using #define allows you to specify a data type for the constant. The const modifier itself prevents the variable from being accidentally modified in an expression and gives the compiler the opportunity to substitute the assigned value as an optimization.
All the programs are tested under Turbo C/C++ compilers. It is assumed that, ?? Programs run under DOS environment, ?? The underlying machine is an x86 system, ?? Program is compiled using Turbo C/C++ compiler. The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:
i) void main() { int const * p=5; printf("%d",++(*p)); }