Code:#include<iostream.h>
int x = 10 ;
void main( )
{
int x = 20;
::x = x + ::x;
cout <<x;
}
Printable View
Code:#include<iostream.h>
int x = 10 ;
void main( )
{
int x = 20;
::x = x + ::x;
cout <<x;
}
Why don't you test yourself and find out ?
Did you forget that we're not compilers ?
ALSO
The program will fail to compile if you use a decent compiler.
(NOT the one from the stone ages that you're using)
It is
int main(), not void .
<iostream> instead of <iostream.h>
std::cout instead of cout. (or a using namespace std; statement)
First of all, it wont compile: it's std::cout (or you can put "using namespace std;" after the include) and you should be including <iostream>, not <iostream.h>.
I'm not going to tell you the output would be if it compiled, because it looks like this is homework or something and there's a policy about not handing out homework answers on this forum. Either deduce what the output should by taking into consideration the scope of each x variable, or get it to compile by fixing it.