+ 3
Ideas for code functions?
im out of ideas to code about functions...somebody can help me?
4 Antworten
+ 7
Function declqration:
def functionname(parameters,*optionalmultipleparameters):
#remember to indent the whole function
return something(optional but if done but once used, no more code runs)
+ 4
look this function example..
function is hard worker child that reduce load of his parents (main function)
#include <iostream>
using namespace std;
int func(int num1,int num 2); //function declaration
int main
{
cout<<"enter two numbers"<<endl;
cin>>x>>y;
cout<<func(x,y); //function calling
return 0;
}
int func(int num1,int num 2)//function body
{
return num1*num2;
}
+ 2
Try a recursive function. For a problem that you normally use iteration, instead create a function that calls itself, using some parameter(s) to control when the iteration ends.
Here's an example of finding fibonnaci with a recursive function: https://code.sololearn.com/cj6THa09XxR9/?ref=app
Recursive functions are very commonly tested for in technical interviews, so try to get exposure to them early on :)
+ 2
Thank you all, I make a code function ;)