-2
#include<iostream> using namespace std; int gvalue=10; void extra(){ cout<< gvalue<<' '; } int main() { extra(); { int gvalue=20; cout<<gvalue<<' '; cout<<gvalue<<' '; } } 

The output which I got was: 10822420 20

I cannot get what is the error? & what does the below section of code mean & work?

extra(); { int gvalue=20; cout<<gvalue<<' '; cout<<gvalue<<' '; } 

Thanks in advance..!! Ignore the bad English.

3

1 Answer 1

4

' ' (note that there are two spaces between apostrophes) is a multi-character literal. Its value is implementation-defined; apparently on your implementation it's 8224 (which happens to be 32 * 256 + 32, in case you are wondering where this number came from; 32 is the ASCII code of the space ' ').

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, I got it.
One more thing I want to ask? What does it mean to have parenthesis after I called the function? Like how does it differ if I just paste the code without parenthesis
Can you explain what line of code you are talking about. You can't remove the parenthesis here: extra(); that would totally change the meaning and make the code do nothing.
The braces are unrelated to the function call. It's just a block aka a compound statement. It's redundant here - braces can be removed without changing the meaning of the program.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.