Explain please

Mar 17, 2014 at 12:31pm
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";
Mar 17, 2014 at 12:37pm
3, 30
7, 3
27, 270
27, 3
Mar 17, 2014 at 12:53pm
@ Suma Menon: please start using code tags.

http://www.cplusplus.com/articles/jEywvCM9/
Mar 17, 2014 at 1:10pm
@Minipaa, thank you very much... How you got the answer? Please explain.
Mar 17, 2014 at 1:28pm
@ 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?
Mar 17, 2014 at 1:32pm
@ 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" :)
Mar 17, 2014 at 1:33pm
yes, but for my exam I cannot use computer, it should write.
Mar 17, 2014 at 1:34pm
so i need to know the meaning of each code.
Mar 17, 2014 at 1:36pm
Mar 17, 2014 at 1:41pm
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.