Explain please

Please explain
Give the output of the following program 2
#include<iostream>
int global = 10;
void func(int &x, int y)
{
x = x-y; y = x * 10;
cout<< x <<' , ' << y << "\n";
}
void main()
{
int global = 7;
func(:: global, global);
cout<<global<<' , '<<::global<<"\n";
func(global, ::global);
cout<<global<<' , '<<::global<<"\n";
3, 30
7, 3
27, 270
27, 3
@ Suma Menon: please start using code tags.

http://www.cplusplus.com/articles/jEywvCM9/
@Minipaa, thank you very much... How you got the answer? Please explain.
@ MiiNiPaa: ha ha, did you "compile and run" in your mind?
http://ideone.com/Wm3LVE

Suma Menon wrote:
How you got the answer? Please explain.

Do you know what a C++ compiler is used for?
If yes, do you have a C++ compiler installed?
If yes, do you know how to use it?
If yes, why aren't you?
@ MiiNiPaa: ha ha, did you "compile and run" in your mind?
Actually, yes. Looks like I need to wait until neuroscience will advance enough to fix a bug in my "compiler" :)
yes, but for my exam I cannot use computer, it should write.
so i need to know the meaning of each code.
Suma Menon wrote:
so i need to know the meaning of each code.

If you want to memorize all the answers, you are doing the wrong thing.
Instead, you should learn the C++ language, then use simple logic to understand what the code does.

Start by reading the tutorials that MiiNiPaa linked to, in his post above.
Topic archived. No new replies allowed.