What would be the output of the following program? main() { int y=128; const int x=y; printf("%d",x); } a) 128 b) Garbage value c) Error d) 0

This question is related to Sonata Interview

Showing Answers 1 - 17 of 17 Answers

pallavi

  • Aug 13th, 2005
 

ans)a

  Was this answer useful?  Yes

Sudheshna.p

  • Jul 7th, 2006
 

the answer is :128(a)

anik

  • Aug 31st, 2011
 

It should have been (a) because constant always needs to be initialized where it declared.

  Was this answer useful?  Yes

ragav

  • Sep 11th, 2011
 

Error, because we cannot change the value of the const variable.

  Was this answer useful?  Yes

Ashok Kumar Orupalli

  • Sep 4th, 2012
 

Answer is a)128. Here we are not modifying const value. We are just assigning value to const variable.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions