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();
}
Options :
  1. 10
  2. Nothing Will be Printed
  3. Compile Error
  4. Run Time Error

Output :

Switch to Variables and Constant MCQ Home :Click Here

How and Why ?
  1. You get Two Errors Here
  2. Const Indicates that the Variable is of Constant Type and Cannot be modified
  3. num = 10 attempts to modify num in Program Which is Illegal
Rules :
  1. Const Variable Should be Initialized as soon as it is declared
  2. Const Cannot be Modified

Errors :
  1. Constant variable 'num' must be initialized 
  2. Cannot modify a const object

  Bookmark & Share

Get Updates Direct in Your Mail Box


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