+ 2

[HELP] Can I use a parameter of a user defined function as a variable in the main function?

No description. That is what it is.

15th Dec 2017, 5:45 PM
Yuvraj Gaonkhowa
Yuvraj Gaonkhowa - avatar
6 odpowiedzi
+ 5
no user defined functions also cannot act as variables
15th Dec 2017, 5:57 PM
Kala Nandini
Kala Nandini - avatar
+ 1
No, you can't. A method can't act like a variable.
15th Dec 2017, 7:27 PM
Mostain
Mostain - avatar
+ 1
No, if you pass a parameter, you need to send the value of that parameter through another variable or value. But the parameter in a function should be used inside the function.
15th Dec 2017, 7:47 PM
Mostain
Mostain - avatar
0
Seems like we cant give user input to it. check a code https://code.sololearn.com/c0IMJwXfJnfR/?ref=app
15th Dec 2017, 6:03 PM
Yuvraj Gaonkhowa
Yuvraj Gaonkhowa - avatar
0
I'm not taking about the whole method, what about the parameters it has?
15th Dec 2017, 7:38 PM
Yuvraj Gaonkhowa
Yuvraj Gaonkhowa - avatar
0
example you gave illustrated scope of x. You seem to think x of the function is the same x in the program. It is not unless you are using a global var x. The only ways to get an output from your function call 1. Set default value for parameter 2. Pass in x (e.g. func(x))
15th Dec 2017, 7:42 PM
H Chiang