Variables & Constant Multiple Choice Questions 1 : Const Variable
Predict the Output of the Following Program if Given Things are -
#include<stdio.h> void main() { const int num ; num = 10; printf("%d",num); getch(); }
- 10
- Nothing Will be Printed
- Compile Error
- Run Time Error
Output :
Switch to Variables and Constant MCQ Home :Click Here
How and Why ?
Rules :
- You get Two Errors Here
- Const Indicates that the Variable is of Constant Type and Cannot be modified
- num = 10 attempts to modify num in Program Which is Illegal
- Const Variable Should be Initialized as soon as it is declared
- Const Cannot be Modified
Errors :
- Constant variable 'num' must be initialized
- Cannot modify a const object

0 comments
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email