Can find where is a problem?

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

What is the problem exactly that you are inquiring about and what output did you expect?

1 Like

Hi,
I expect both numbers must be 43, but second number is 0.
Thanks

I am not sure how you can compile this but you should not be able to since inside your main you are trying to output a variable named number without it being globally accessible but rather it’s only accessible inside the smiley() method.

That’s why your program does not run properly.

I would personally suggest using a different IDE.

1 Like

number is globally accessible. It is declared outside of main in global scope.
The program outputs exactly as it should.

1 Like

This example seems like a lesson on global and local scope

If you want to access the same variable inside main and in smiley, then you shouldn’t declare number again in the smiley function.
That means using
number = 43;
instead of
int number = 43
in the smiley function.

1 Like

I already realized this myself.

Thanks