Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

Give output of following code. #include int m=5; void check(); void main( ) { int m=20; { int m=10*::m; cout<<"m="<13 years ago

OpenStudy (anonymous):

@shubhamsrg

OpenStudy (shubhamsrg):

I have forgotten almost all in c.sc. Still i can try though @DLS can help you most probably.

OpenStudy (shubhamsrg):

won't there be error "multiple declaration of m" ?

OpenStudy (shubhamsrg):

in void main()

OpenStudy (shubhamsrg):

and, again, how did my comment get up! -__-

OpenStudy (dls):

m=50 ::m=5 m=20 ::m=6

OpenStudy (dls):

::m=7 m=20

OpenStudy (dls):

thats it

OpenStudy (anonymous):

Can u Explain....its working

OpenStudy (dls):

What does :: do?

OpenStudy (anonymous):

idk

OpenStudy (dls):

:/

OpenStudy (dls):

It refers to the global variable for short

OpenStudy (dls):

If I have a program,where #include<iostream.h> int x=5; void main() { int x=10; cout<<x; |

OpenStudy (dls):

can you tell the outupt

OpenStudy (anonymous):

10

OpenStudy (dls):

why not 5?

OpenStudy (anonymous):

(i) Execution starts from main function (ii) Overwrite

OpenStudy (dls):

NO! Who told you overwrite?!

OpenStudy (dls):

Global variables are stored in "Data segment" of memory. And local variables at "Stack" They are completely 2 different parts of memory. http://www.tenouk.com/ModuleZ_files/cmemory003.png

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!