Const - Find Output of Program :: Discussion


8.What will be the output of the program?
A.10
B.11
C.No output
D.Error: ++needs a value
Answer:  Option  D
Explanation:

This program will show an error "Cannot modify a const object".

Step 1const int i=0; The constant variable 'i' is declared as an integer and initialized with value of '0'(zero).

Step 2printf("%d\n", i++); Here the variable 'i' is increemented by 1(one). This will create an error "Cannot modify a const object".

Because, we cannot modify a const variable.

Tutorial Link:
Published by:Michael Daani

Comments are not available

Post your comments here:

Optional

Date to Date Current Affairs 2022

PakMCQs.net

Quick Links

GAT Subject



   Computer Science    English Mcqs    Agriculture    

Engineering



   Computer Science    Civil Engineering    

Technical



   Networking    Electronics    Database    

Past Papers



   Model Papers    FPSC Papers