#Why can the parameter be different calling the same function?

18 messages · Page 1 of 1 (latest)

faint gardenBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

outer marlin
#

Help please

#

Why can the parameter be different calling the same function?

royal ingot
#

Because n is int type

#

And the function expects a single int parameter

outer marlin
chilly bobcat
#

you can also call print_grid(3) for example

#

and 3 is not a valid variable name

#

n is not related to size because they are different variables in different scopes

#

also this looks like C, so you should be asking in #1013104018739974194 instead

royal ingot
#

The name of the parameter is just the name you choose to be used in the function

#

The actual value passed in doesn’t have a name, it’s just a value

outer marlin
#

Ah ty

faint gardenBOT
#

@outer marlin Has your question been resolved? If so, run !solved :)

rotund plume
#

Interpret it as
int size = n
That's how function arguments work internally.
(Note: The above syntax is only for understanding purpose)

outer marlin
#

!close

faint gardenBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity