Multiple choice

Find out the output of the following program or error (if any).

#include<stdio.h>
#include<conio.h>
int main()
{
 const int num=12;
 ++num;
 printf("num=%d",num);
 getch();
}

  1. Num=12

  2. Num=13

  3. Garbage value

  4. Error in the program

  5. Blank screen (no output)

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

There is an error in the program. We have declared the num variable as constant by const keyword. So, in this program we cannot modify its value. The compiler will give an error that “ cannot modify the constant object” or “[error] increment of read only variable num”. So, this option is true.