+ 2

Can't use an assigned variable elsewhere.

Can someone please explain why x,y and z can't be used outside the functions? I tried declaring them outside the functions but then they can't be read IN the functions. What I don't get is why it doesn't show outside the function. I even tried using const but no difference. https://code.sololearn.com/WHM5APcD3Ivh/?ref=app

19th Oct 2019, 12:02 PM
SolomonDavid Akesoba
SolomonDavid Akesoba - avatar
2 Antworten
+ 2
Avi Pheimei Konyak when I do that, I can't use them in the function.
19th Oct 2019, 6:50 PM
SolomonDavid Akesoba
SolomonDavid Akesoba - avatar
0
Those x y and z variables are local variables, meaning they can be used only side the function in which they were created. You'll need to declare them outside the function to be able to use them
19th Oct 2019, 2:02 PM
Avi Sayen
Avi Sayen - avatar