+ 1
What does function mean ?
Function
10 Respuestas
+ 6
Function:
Function is an operation, which takes in values and processes them to return new values.
Function in programming:
In programming, functions are defined, named block of code, that will be executed when called.
Function is called, when you execute function_name();
Example (Python):
>>>def sum(x, y):
... return x + y
...
>>>print(sum(5, 7))
12
>>>#12 was printed, because 5 was passed in sum as x "x = 5", and 7 was passed in sum as y "y = 7", and sum returned x + y "return 5 + 7" => "return 12".
>>>#It returned 12 where sum was called (in print statement) then print was called with 12 as argument, then print printed 12
+ 2
Yes, functions are a great way to do things. You can make many as you need. The term "function" is from math, basically is the same thing.
I don't know Python enough but some other languages have a "Main Function" and that's the function the program execute in order to run.
You can create many functions to accomplish what you want but in order to use those you need to call them inside the "Main function".
Almost every language works at similar manner but to be more precise, what language do you use?
+ 2
C++
+ 1
Thanks. So if I'm not wrong function means the main thing right ?
+ 1
Can you please give some examples
+ 1
Sure..
Look at this code:
If you comment or erase the method "SayHi();" inside Main method, the program will do nothing. That's because the program only execute things inside the Main.
https://code.sololearn.com/cmD3uYH3620d/?ref=app
+ 1
If you want more info you can watch the video in this link. It is a great YouTube channel for beginners in almost every mayor language.
https://www.youtube.com/playlist?list=PLLAZ4kZ9dFpOSzRXG05goZMgsvXwDDL6g
+ 1
Seb TheS The code is good for some advance fellow programmers. It is better try to not show off but make it simpler in order to explain something (it is a good code though).
At least you can comment it to explain your answer...
Baby steps, ma' friend.